Java exercises Assignment 02

Java exercises Assignment 02

Java exercises Assignment 02

Java Exercises Best Questions


Question 01:

Write a Java program to create a class called "Faculty" with a name and 

Designation attribute. Create two instances of the "Person" class, set 

their attributes using the constructor, and print their 

name and age.

[Solution No 01]


Question02:

 Write a Java program to create a class called "BankAccount" with a collection of accounts and methods to add and remove accounts and deposit and withdraw money.

[Solution No 02]

Question03:

Take an array of 10 elements. Split it into middle and 

store the elements in two dfferent arrays. E.g.-

INITIAL array :

58 24 13 15 63 9 8 81 1 78


Split Array 01:

58 24 13 15 63


Split Array 02:

9 8 81 1 78

[Solution No 03]


Question04:

  Write a program that would print the information 

(name, year of joining, salary, address) of three employees by creating 

a class named 'Employee'. The output should be as follows:

Name        Joining Year    Address

Saif        2012            Islamabad

Abdullah    2021            Lahore 

iFarooq      2021            Karach


[Solution No 04]


Question05:

Take an array of length n where all the numbers are 

nonnegative and unique. Find the element in the array possessing the 

highest value. Split the element into two parts where first part 

contains the next highest value in the array and second part hold the 

required additive entity to get the highest value. Print the array 

where the highest value get splitted into those two parts.


Sample input: 4 8 6 3 2


Sample output: 4 6 2 6 3 2


[Solution No 05]


Question06:

 Why Scanner class is used? Use Scanner class to read student names 

in an array of size 10 and then display the names of those students 

which contains word “Rehman” in their names.


[Solution No 06]

Question07:

Define the following Java concepts

    1. private, public and protected

    2. constructor

    3. JRE, JDK, JVM

    4. Super keyword


[Solution No 07]




0 Response to "Java exercises Assignment 02"

Post a Comment