CSE111 Lab Assignment 2 - Fall'24
CSE111 Lab Assignment 2 - Fall'24
Number of Tasks: 11
[Submit all the Coding Tasks (Task 1 to 8) in the Google Form shared on buX
before the next lab. Submit the Tracing Tasks (Task 9 to 11) handwritten to your
Lab Instructors at the beginning of the lab]
[You are not allowed to change the driver codes of any of the tasks]
Task 1
You are given the following “University” class:
a. Write the main method and create 2 objects of University class and print the location of
the objects and print the instance variables of the objects. Are the location of the objects
the same?
Now check if the instance variables of both objects have changed or not and whether the
instance variables of both objects are of the same value or not.
Task 2
Design the “Student” class so that the main method prints the following:
Design the CSECourse class to generate the correct output from the driver code provided
below:
Task 4
Design the “ImaginaryNumber” to generate the output given below:
Design the Course class to generate the correct output from the driver code provided
below:
Driver Code Output
Task 6
Task 7
Design the CellPhone class so that the main method of tester class can produce the
following output:
Task 8
Driver code:
public class Tester11 { Outputs
public static void main(String [] args){
Task11 t1 = new Task11 (); x y Sum
t1.methodA();
t1.methodA();
}
}
Ungraded Tasks (Optional)
(You don’t have to submit the ungraded tasks)
Task 1
Complete the “Cat” class so the main method produces the following output:
Task 2
Complete the Bird class so that main method produces the following output:
Task 3
Implement the “ChickenBurger” class with necessary properties, so that
the given output is produced for the provided driver code.
[Note:
1. There are four available spice levels: Mild, Spicy, Naga and
Extreme. You can store these values in a String array.
2. You might need to use the .equals() method to compare two string
values.]
Task 4
3 public int y;
7 y = this.y + msg[0];
8 methodB(++msg[1], msg[0]);
9 x = x + this.y + msg[1];
10 sum = x + y + msg[0];
12 }
14 int x = 0;
15 y = this.y + mg2;
16 x = x + 19 + mg1;
17 sum = this.sum + x + y;
18 mg2 = y + mg1;
19 mg1 = mg2 + x + 2;
22 }