Unit-3 - Practical Assignment
Unit-3 - Practical Assignment
1. Write a program in java to take an 2D array from user and display sum of all even
numbers present in that array.
2. Write a program in java to take an 2D array from user and display all prime numbers
present in that array.
3. Write a program in java to take an 2D array from user and display all elements if array
in ascending order.
4. Write a program to create an array of any user defined size and print all even numbers
and odd numbers in a specified range.
5. Create 1D array of 10 numbers and print them in descending order.
6. Demonstrate the use of variable argument list with the help of an example.
7. Write a program which take an array as an argument to a function, sort it and return it
back to main program.
8. Define a class MotorVehicle to take modelName, modelNumeber, modelPrice, and a
method display() to display these details. Create another class Car which inherits the
class MotorVehicle and has the member discountRate and having display() method to
display details. Test this class with suitable constructor. If necessary use the super
keyword.
9. Consider an employee class, which contains fields such as name and designation. And a
subclass, which contains a field salary. Write a program for inheriting this relation.
10. Write a program to find Maximum element from an Array.
11. Write a program to calculate arithmetic mean in the superclass and standard deviation
in the subclass.
12. Write a program to calculate the area of circle, Rectangle & Square by using interface.
13. Write an interface called Numbers with a method int process(int x,int y). Write a class
called Sum in which the process() method finds the sum of two numbers and returns an
int value. Write another class called Average in which the process() method finds the
average of the two numbers and returns an int value.
14. Create a class name Book that contains data fields for the title and number of pages.
Include get and set methods for these fields. Next, create a subclass named Textbook,
which contains an additional field that holds a grade level for the Textbook and
additional methods to get and set grade level field. Write an application that
demonstrates using objects of each class.
15. Write a program in Java in which a subclass constructor invokes the constructor of the
super class and instantiate the values.
16. Write a program in Java to demonstrate implementation of multiple inheritance using
interfaces.
17. Create a class with a method that prints "This is parent class" and its subclass with
another method that prints "This is child class". Now, create an object for each of the
class and call -
method of parent class by object of parent class
method of child class by object of child class
method of parent class by object of child class
18. Write a Java Program to create a simple class to find out the Area and perimeter of
rectangle and box using super and this keyword.
19. Write a Java program to create an interface area having pie as its data members and a
method compute(float, float)
20. Create a class result which implements sports interface having data member total (stores
total of three subject marks) and percentage (total + sportmarks). Calculate the
percentage and grade and display the same.
21. Create a class named 'Rectangle' with two data members 'length' and 'breadth' and two
methods to print the area and perimeter of the rectangle respectively. Its constructor
having parameters for length and breadth is used to initialize length and breadth of the
rectangle. Let class 'Square' inherit the 'Rectangle' class with its constructor having a
parameter for its side (suppose s) calling the constructor of its parent class as 'super(s,s)'.
Print the area and perimeter of a rectangle and a square.
22. Create a class named 'Shape' with a method to print "This is This is shape". Then create
two other classes named 'Rectangle', 'Circle' inheriting the Shape class, both having a
method to print "This is rectangular shape" and "This is circular shape" respectively.
Create a subclass 'Square' of 'Rectangle' having a method to print "Square is a
rectangle". Now call the method of 'Shape' and 'Rectangle' class by the object of 'Square'
class.