Homework Assignment 1
Homework Assignment 1
Homework Assignment 2
1. Create a Cuboid class with 3 public instance variables length, breadth and height of type double,
and a method volume (). Create 2 objects with different values obtained by command line
arguments and print the volume of each. (The program must take 6 values as input)
2. Write a Java Program to create Student class with ID, name, gender, and branch. Use getter and
setters. The ID must be 9-digit number, name must not have special characters and digits,
gender must be either M/F and branch must be either ECE/CSE/ME/ECSE/CE/BT/EEE. Use
toString () to format the details of Student. Read data from console and create 2 student objects
and print the data of each student.
3. Create a class Address with instance variables city, state, and country of String type. create a
parameterized constructor and a toString (). Create a class Employee with instance variable id
of type int, name type String, and address of type Address. Create a parameterized constructor
and a toString (). And create 2 objects for the class Employee and print the details of each
object in main () of different class.
4. Predict the output of the following and explain your output
package p1;
public class Vehicle {
void run(){
System.out.println("The vehicle runs");
}
}
public class Car extends Vehicle{
void run(int x){
System.out.println("The Car runs at speed of 10 KM per hour.");
} }