You are on page 1of 3

1.)Differences between static and instance members of class .

2.)Explain the different Types of Access Specifiers with Example.


3.) Define Class and objects with example .
4.) The Election Commission requires the following task to be
done. A class Voter with ID,cname, age and address as fields.
Write toString() , getter methods and setData()
method.TheVoterDemo has main () method which reads and
stores data of 10 voters anddisplays a menu with following
operations:
a) Add new voter.
b) Search voter based on ID.

5.)Create a class Address with instance variables city, state, and


country of String type. create aparameterized constructor and a
toString (). Create a class Employee with instance variable idof
type int, name type String, and address of type Address. Create a
parameterized constructorand a toString (). And create 2 objects
for the class Employee and print the details of eachobject in main
() of different class.

6.) Create a class Utility with three static methods add () the first
add () will take 2 arguments, add them, and return the result,
second add () will take 3 arguments, add them, and return the
result,third add () will accept an array of integers, add elements
in the array and return the result.
Invoke the all the three overloaded methods from main () within
the same class

7.)Draw the class diagram for the following and Develop a java
program that reads the number of kilograms of type double,
through console, converts it to pounds, displays the result.(HINT:
1kg = 2.2046 pounds )
8.) A Company launched app is to be launched. The task is to
store data of customer in a class with attributes customer Name,
Mobile, distance and fare. Write mutators for
a) name – has only characters
b) mobile – 10 digits
c) distance - must be a positive value (in terms of kms)
A method to compute fare at the rate of Rs.20 per km and
toString() method to print
data. Modularize to package level with main () in PassengerDemo
class to create an
object and obtain the data through console.

9.) 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)

10.)Develop a java class to read data of 10 students (With ID,


name, gender, age as private instance members). Draw the class
diagram and define the following methods
a) toString ()
b) setDetails ()
the main () method must create an array, store reference of 10
students. There must be menu with the following options:
1.New Student
2.Print all Students
3.Search based on ID
4.Exit ..Use Switch case as it’s a menu driven… use
System.exit(0); for exit method in java
11.) Draw the class diagram based on the following specifications:
Create a class cricket player with the following private attributes-
name, country, matches Played, total runs. Code the constructor,
toString() methods. the main() method must store data of 5
crickets in an array and is menu driven with the following
options: 1. Add new Cricketer, 2. Display data of players who
player more than 50 matches.

12.)Assume a class book with the following attributes -


ISBN(long), Title(String), price(double), year(integer). Write the
parameterized constructor with 4 arguments and draw the class
diagram.

13.) Use Command Line arguments Create a class Utility


with three static methods add() the first add () will take 2
arguments, add them, and return the result, second add ()
will take 3 arguments, add them, and return the result,
third add () will accept an array of integers, add elements
in the array and return the result. Invoke the all the three
overloaded methods from main() within the same class

You might also like