Assignment 2 Set A to C
Assignment 2 Set A to C
Assignment No. 2: Classes, Objects and Methods
Set A
Write a java program to calculate area of Cylinder and Circle. (Use super keyword)
Define an Interface Shape with abstract method area(). Write a java program to calculate an area of Circle
and Sphere.(use final keyword)
Define an Interface Integer with a abstract method check().Write a Java program to check whether a given
number is Positive or Negative.
Define a class Student with attributes rollno and name. Define default and parameterized constructor.
Override the toString() method. Keep the count of Objects created. Create objects using parameterized
constructor and Display the object count after each object is created.
Write a java program to accept n integers from the user & store them in an ArrayList collection. Display the
elements of ArrayList collection in reverse order.
Set B
Define a class person(pid,pname,age,gender). Define Default and parameterised constructor. Overload the
constructor. Accept the 5 person details and display it.(use this keyword).
Define a class product(pid,pname,price). Write a function to accept the product details, to display product
details and to calculate total amount. (use array of Objects)
Assignment 2 Set A to C
Define a class Student(rollno,name,per). Create n objects of the student class and Display it using
toString().(Use parameterized constructor)
Define a class MyNumber having one private integer data member. Write a default constructor to initialize it
to 0 and another constructor to initialize it to a value. Write methods isNegative, isPositive. Use command line
argument to pass a value to the object and perform the above tests.
Set C
Define class Student(rno, name, mark1, mark2). Define Result class(total, percentage) inside the student
class. Accept the student details & display the mark sheet with rno, name, mark1, mark2, total, percentage.
(Use inner class concept)
Write a java program to accept n employee names from user. Sort them in ascending order and Display
them.(Use array of object and Static keyword)
Write a java program to accept details of n cricket players(pid, pname, totalRuns, InningsPlayed,
NotOuttimes). Calculate the average of all the players. Display the details of player having maximum
average.
Write a java program to accept details of n books. And Display the quantity of given book.