You are on page 1of 4

Object Oriented Programming using Java

Assignment List 4

Topics Implementation – Class Attributes, Class Method , Class Constructor, Class


Parameterized Constructor , Object Hash Code

1. Create two classes Person and Demo Person. Run and Observe the output of
this code.
2. Add Default Constructor to the Persons Class using below code and Test the
Code .

Identify what is wrong in the Output of this code.


3. Now to Fix the Issue in the output , add parameterized Constructor for the
Person class
4. Create Class Car. Add below DataTypes to the Car Class. (Class Variables and
not variables in main method)

byte, short , int, long , float, char, String

Create Method showCarDetails() to print the Car Class Attributes. (Similar to


talk() method in above examples )

1. Add Main Method

2. Create Object Car Maruti = new Car();

3. Print hashcode of Maruti Object using below line :

System.out.println("Object Hashcode is "+Maruti.hashcode());

4. Maruti. showCarDetails();

5. List down all the default values assigned to Car Class by JVM.

You might also like