Make your own free website on Tripod.com
Assignment 1 (Due Date: 25/9)
Q1. Modify, compile, and run the HelloWorld program so that it prints the following

   "This is my first Java program" (instead of "Hello world")

Q2. Please play around with the classpath settings with -classpath or -cp option and CLASSPATH environment

Assignment 2(Due Date: 25/9)
Q1. Create a new NetBeans project called "MyOwnHelloWorld" from scratch.
The program should display the following text when it runs.
     This is my own NetBeans project, and I am damn proud of it.

Assignment 3(Due Date: 25/9)
Q1. Modify ConditionalOperator.java as adding the following lines of code at the appropriate place, compile and run the code
Do the homework both using command line tools and using NetBeans.

Assignment 4(Due Date: 29/9)
Q1. Modify GreatestValue.java code so that it displays the greatest number and smallest number .

Assignment 5(Due Date: 2/10)
1. Modify GetInputFromKeyboard.java as following, compile and run the code
Do the homework either at the command line or using NetBeans.

Assignment 6(Due Date: 2/10)
1. Modify GetInputFromKeyboardJOptionPane.java as following, compile and run the code
Do the homework either at the command line or using NetBeans.

Assignment 7(Due Date: 9/10)
Homework

1. Modify Grades.java as following, compile and run the code. 
Assignment 8(Due Date: 9/10)
Homework:

1. Modify NumWords.java as following, compile and run the code

Assignment 9(Due Date: 9/10)
Homework:

1. 1. Modify ArraySample.java as following, compile and run the code
Do the homework either at the command line or using NetBeans.

2.Create a new NetBeans project which contains NamesAndAgesOfMyFamily.java source file as following:
Hint: You can see an example of 2-dimentional array from "Array of Arrays" Java tutorial

Assignment 10 (Due Date: 16/10) (This assignment is optional, But I would appreciate those who can do it.)
Homework:

1. Create a new NetBeans project which contains GreatestNameLength.java source file as following:
Hint: You will have use various methods of String class.  The following is an example code fragment you might be able to use.  Please feel free to use alternative ways of doing the homework.

// Get the first name from a name string using split() instance (non-static) method
String[] nameArrayForPerson1 = person1NameInstance.split(" ");
String[] nameArrayForPerson2 = person2NameInstance.split(" ");

// Get the lengths of strings using length() instance (non-static) method
int lengthOfFirstNameOfPerson1 = nameArrayForPerson1[0].length();
int lengthOfFirstNameOfPerson2 = nameArrayForPerson2[0].length();

// Compare the lengths of the first names between person1 and person2
if (lengthOfFirstNameOfPerson1 > lengthOfFirstNameOfPerson2){
   System.out.println(nameArrayForPerson1[0] +
                              " has longer first name than " +
                              nameArrayForPerson2[0]);
}



Assignment 11(Due Date: 6/11)
1. Modify ClassAndObject.java as following, compile and run the code


Assignment 12(Due Date: 6/11)
1. Write StaticAndInstanceMethods2.java as following, and compile and see what compile errors you get.  Fix any compile errors.

public class StaticAndInstanceMethods2{

    public static void main( String[] args ){
     
        // Create an instance of a String class by using a keyword "new".
        // For example, in order to create an object instance of a String class,
        // you will do the following
        String strInstance1 = new String ("I am object instance of a String class");
      
        // The following code will generate a compile error since you are trying to
        // invoke a instance method through a class.   Fix this compile error.
        char x = String.charAt(2);

    }

}
Code 9.2.b: StaticAndInstanceMethods2.java

Assignment 13(Due Date: 6/11)

1. Modify TestPassByValue.java as following. Compile and run the application. 


Assignment 14(Due Date: 6/11)

1. Write EqualsTestInteger.java as following.  Compile and run the application.


Assignment 15(Due Date: 6/11)
Q1.
 Modify StudentRecord.java as following
Modify StudentRecordExample.java as following Compile and run StudentRecordExample application


Assignment 16(Due Date: 6/11)
Q1. Modify StudentRecord.java as following
Modify StudentRecordExmaple2.java as following


Assignment 17(Due Date: 6/11)
1. Write a class called Food under foodpackage.fruitpackage pacakge
Write a class called FoodMain under foodpackage.fruitpackage package
Compile and run the code

Hint: The goal of this homework exercise is to let you experience s two-level package structure instead of just one.  For example, the "foodpackage" is a parent package of the "fruitpackage" package. And each should have its own directory and they should reflect the parent and child relationship of the package structure. What this means is that you would have to create foodpackage directory first and then fruitpackage directory underneath it.  Then you will create Food.java and FoodMain.java under fruitpackage directory.



Assignment 18(Due Date: 13/11)
1. Write TuftsStudent.java as following
2. Modify the Main.java to create an instance of TuftsStudent class as following
3. Compile and run the code. You should see the following:
Assignment 19(Due Date: 13/11)
1. In your TuftsStudent class, override getHobby() and setHobby() methods of the Student class as following
2. Change Main.java to invoke setHobby() and getHobby() methods of the newly created TuftsStudent object instances as followoing.
3. Compile and run the code.  You should see the following result.
Assignment 20(Due Date: 13/11)
1. Write another class called Teacher.java as following
2. Modify the Main.java in which, getName() method of the Teacher object gets called
3. Compile and run the code.  You should see the following result.
Assignment 21(Due Date: 20/11)
1. Define another abstract method in the LivingThing.java as following
2. Implement a concrete method in the Human.java that implements the dance() abstract method.
3. Compile and run the code

Assignment 22(Due Date: 20/11)

Define your own package (for example, myownpackage)
Define an interface called PersonInterface.java under the package above.  This interface containt the following abstract methods.
Define another interface called SportInterface.java under the package above.  This interface containt the following abstract methods.
Define the third interface called HobbyInterface.java under the package above.  The interface contains the following abstract methods.
Write a class called SportAndHobbyImpl.java that implements the all three interfaces defined above - PersonInterface, SportInterface and HobbyInterface interfaces.  Provide whatever approproate business logic in the methods that implement the abstract methods defined in these three interfaces.

5. Write MyMain.java as following.
Assignment 23(Due Date: 27/11)
Q1. Using JDBC, Create a table COFFEES
Table COFFEES has following fields
   COF_NAME varchar(32)
   SUP_ID int
   PRICE float
   SALES int
   TOTAL int

Q2. After creating table, Insert Records in the table COFFEES.
Your program should work as follows
   Ask the user before inserting a record.
   If user says yes, then get the value of fields from him
   After receiving values from user, insert the record
   Again ask the user if he want to insert a record, i.e. go to step1.
   Repeat these steps until user answers NO


Q3. After Q2 is finished, display all the record in table format.