CSE111 Lab Assignment 9 - Summer'24
CSE111 Lab Assignment 9 - Summer'24
Number of Tasks: 11
Task 1
Given the following classes, write the code for the BBAStudent class so that
the following output is printed when we run the TestStudent class.
//Tester Class
public class TestStudent{
public static void main(String [] args){
BBAStudent b1 = new BBAStudent();
BBAStudent b2 = new BBAStudent("Humty Dumty");
BBAStudent b3 = new BBAStudent("Little Bo Peep");
b1.details();
System.out.println("1---------------");
b2.details();
System.out.println("2---------------");
b3.details();
}
}
Task 2
Given the following classes, write the code for the Vehicle2010 class to
print the following output when we run the Vehicle2010User class.
//Tester Class
public class Vehicle2010User{
public static void main(String[] args){
Vehicle2010 car1 = new Vehicle2010();
car1.position();
car1.moveLowerLeft();
car1.position();;
//Tester Class
public class TestAccount{
public static void main(String [] args){
System.out.println("Total Checking Accounts:
"+CheckingAccount.count);
CheckingAccount c1 = new CheckingAccount();
System.out.println("Account Balance: " + c1.showBalance());
CheckingAccount c2 = new CheckingAccount(100.0);
System.out.println("Account Balance: " + c2.showBalance());
CheckingAccount c3 = new CheckingAccount(200.0);
System.out.println("Account Balance: " + c3.showBalance());
System.out.println("Total Checking Accounts:
"+CheckingAccount.count);
}
}
Task 4
Design the Dog and Cat class derived from the Animal class with appropriate
attributes and properties so that the driver code can generate the output
given below.
Driver Code Output
public class Animal { 1.========
public String name; Name: Buddy
public int age; Age: 5
public String color; Color: Brown
Breed: Bulldog
2.========
public Animal(String name, int age, String color) { Name: Kitty
this.name = name; Age: 3
this.age = age; Color: White
this.color = color; Breed: Persian
} 3.========
Brown color Buddy is barking
public void makeSound() {
4.========
System.out.println("Animal makes a sound"); White color Kitty is meowing
}
public String info() {
return "Name: "+name+"\nAge: "+age+"\nColor: "+color+"\n";
}
}
//Tester Class
public class AnimalTester {
public static void main(String[] args) {
Dog dog = new Dog("Buddy", 5, "Brown", "Bulldog");
Cat cat = new Cat("Kitty", 3, "White", "Persian");
System.out.println("1.========");
System.out.println(dog.info());
System.out.println("2.========");
System.out.println(cat.info());
System.out.println("3.========");
dog.makeSound();
System.out.println("4.========");
cat.makeSound();
}
}
Task 5
Implement the design of the Account class so that the following output
is produced:
2 int x = 2, y = 4, sum = 3;
11 }
14 int a = (arr2[0]++) - q;
15 int b = (++arr2[1]) - n;
16 return a + b;
17 }
20 return z/2;
21 }
22 }
public class Tester1{ Outputs
public static void main(String [] args){
Test1 t1 = new Test1();
t1.methodA(7);
}
}
Task 10
Task 11