0% found this document useful (0 votes)
240 views56 pages

HefShine Core Java BookletV7

This document provides an introduction to programming languages and Java. It discusses subtopics like the need for programming languages, different types of programming languages like assembler, compiler and interpreter. It then focuses on the history and components of Java like JDK, JRE and JVM. The document also includes assignments and interview questions related to programming languages and Java basics.

Uploaded by

John Bell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
240 views56 pages

HefShine Core Java BookletV7

This document provides an introduction to programming languages and Java. It discusses subtopics like the need for programming languages, different types of programming languages like assembler, compiler and interpreter. It then focuses on the history and components of Java like JDK, JRE and JVM. The document also includes assignments and interview questions related to programming languages and Java basics.

Uploaded by

John Bell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Topic: Introduction

SUBTOPICS:
1) IntroDUCtion to Programming LangUages
2) Need to learn Programming LangUAges
3) Concept of Assembler, Compiler, Interpreter
4) What is Java
5) History of Java
6) JDK,JRE,JVM
7) How To set Path
8) Installation of Eclipse

C/W ASSIGNMENTS:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Installation of Eclipse.
2) How to Use Notepad/Eclipse Editor
3) How to set path.
H/W Assignments:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Installation of Eclipse.
2) How to set path.
Interview Questions:
1) What are Programming languages?
2) What is the difference between compiler and interpreter?
3) What are the differences between C, C++ and Java?
4) What do you know about Java?
5) When and by whom was Java Developed?
6) What is the difference between JDK, JRE, and JVM?

1|Page
Topic: Social Presence

1) Email
• Id, Name, dp, Signature, email etiquettes
2) Facebook
• Id, Name, dp, posts, religious/cast posts, Technology Posts
3) Instagram
• Id, Name, dp, posts, religious/cast posts, Technology Posts
4) LinkedIn
• Dp, Name, Designation, Skills, recommendation to skills, connections, follow, posts, likes
• Mention link in your resume
5) Mobile
• Caller tune, Ring tone
• Mention in resume with space separated digits i.e. +91 9890 123 123
6) GitHub
• Upload all your assignments and mention this id in your resume

2|Page
Topic: Basics Of Java

SUBTOPICS:
1) FeatUREs of Java
2) What is a program
3) Comments, Data Types
4) Literals, Identifiers
5) Operators
6) Program stRUCtURE
7) Hello world program

C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.

1. Write a program to print 'Hello' on screen and then print your name on a separate line.
2. Write a program to two numbers and perform sum of two numbers.
3. Write a program to calculate Simple Interest.
4. Write a program to swap two variables (with and without third variable)
5. Write a program to convert days into years, weeks and days.{Hint: Input-373 days Output-1Year,1Weak,1day}
(Variations)
6. Write a program to find Compound Interest. (Variations)
r
A = P(1 + )nt
n
Where A= Amount (Principle + Interest)
P= Principle, r= Rate of interest, n =number of times interest applied per time period,
t= number of time periods elapsed
7. Find the output of following series (Feb 2019 Monthly Exam)
int k = 2;
System.out.println(k++ - ++k + k-- - k++ + ++k -k-- + --k + k+ k--- k + --k+ k++);

H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Write a program to divide two numbers and print on the screen.
2) Write a program to print the sum (addition), multiply, subtract, divide and remainder of two numbers
3) Write a program to print the area and perimeter of a circle.
area = πr 2 perimeter = 2πr
4) Write a program to print the area and perimeter of a rectangle
5) Write a program to find the area of an equilateral triangle.
6) Write a program to convert Celsius into Fahrenheit and viceversa. (Variations)
9
F = 32 + C
5
7) Write a program to display total Marks and average of 6 subjects. (Variations)
8) Print following message on consol
1)Hef ” Shine
2) “HefShine”
9) Print a message on two lines using only one sys out statement
Output: Hef
Shine

3|Page
Aptitude
Trains
1. A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train?
A.120 metres B.180 metres C.324 metres D.150 metres
2. A train 125 m long passes a man, running at 5 km/hr in the same direction in which the train is going, in 10
seconds. The speed of the train is:
A.45 km/hr B.50 km/hr C.54 km/hr D.55 km/hr
3. The length of the bridge, which a train 130 metres long and travelling at 45 km/hr can cross in 30 seconds, is:
A.200 m B.225 m C.245 m D.250 m
4. Two trains running in opposite directions cross a man standing on the platform in 27 seconds and 17 seconds
respectively and they cross each other in 23 seconds. The ratio of their speeds is:
A.1 : 3 B.3 : 2 C.3 : 4 D.None of these
5. A train passes a station platform in 36 seconds and a man standing on the platform in 20 seconds. If the speed of
the train is 54 km/hr, what is the length of the platform?
A.120 m B.240 m C.300 m D.None of these
Interview QUEstions:
1) What gives Java its 'write once and run anywhere' nature?
2) Why is Java platform independent?
3) Explain the structure of a program.
4) Why comments are used in a program?
5) What are data types?
6) What are variables? What are the rules to name a variable?
7) What are keywords? Name few.
8) What are identifiers and literals?
9) What are operators?
10) Name different types of operators.
11) Explain public static void main (String args []).
12) Can we execute a program without main () method?
13) What are the types of relational operators in Java?
14) What are the logical operators in Java?
15) What are called as Arithmetic operators?
16) State the name of / and % operator and explain how will you use this?
17) Which are the two relational operators that are called asequality operators? Give an example.
18) How will you represent increment and decrement operators?
19) What is a ternary operator? Give an example.
20) State the use of instance of operator. Give an example.
21) Discuss the significance of the Java language. 22)Elaborate briefly upon the evolution of Java.
23)Compare in brief C/C++, C#, and Java. 24)Elaborate on the main features of Java.

4|Page
Resume Writing
1) Curriculum Vitae(CV) or Resume?
The CV presents a full history of your academic credentials, so the length of the document is variable. In
contrast, a resume presents a concise picture of your skills and qualifications for a specific position, so length
tends to be shorter and dictated by years of experience (generally 1 pages).
2) Your resume format must be of one page, unique and colorful
a. Why One Page?: (No one have time to read 2-3 pages per candidate before taking interview)
b. Why Unique? (The person who can‟t even take efforts to build his own cv, how will he take efforts to
build his career?)
c. Why Colorful? (It looks happening, black and white is comparatively boring)
d. Hint: search on google images for “One page resume” so you will get many samples. And search
“resume design format tutorial” on Youtube to get idea about how to prepare resume in word
3) How to share your resume
a. You must share your resume in PDF file ONLY
b. Name of file must be your full name with proper casing. e.g “Shankar Kishor Patil.pdf”
Please Note: First character of every word is capital rest are small and one space after every word
c. Ensure there is spelling mistakes in your resume (Most Important) (ask 5-6 friends to review it)
4) Preferred Sequence
a. Name
i. It is recommended to use exact same name as per adhar card or graduation certificate
b. Contact Details
i. Mobile No: write mobile number in space separated (4 3 3) manner e.g +91 9850 123 123, it is easy
to read. Ensure that mobile will always be with you
ii. Try to keep same number for calls as well as whatsapp
iii. Address: Keep your address short and comma separated. First character of village, city, district, state
must be capital.
iv. Email id: id and name should be professional
v. LinkedIn profile link
vi. GitHub Profile link
c. Photo
i. Photograph in Resume is always preferred
ii. Strictly professional photo
iii. Passport size preferred where face covers 70% of area of photo
d. Career Objective
i. Must be unique (The person who can‟t even take efforts to build his own cv, how will he take efforts
to build his career?)
e. Experience
i. You can add your HefShine‟s software trainee experience in your resume
f. Education Details
i. Please ensure you have below points in your resume
1. Admission year
2. Passing Year
3. Branch
4. Aggregate Percentage
5. University or a college name (If you are from reputed college then mention it in resume else
mention only university).
6. Education details in table formats and as minimum and to the point as possible
For e.g., B.E. - (Admission year-Passout year) - IT
BE - (2016-2020 ) - IT
g. Technology Exposure
i. Enlist only those technologies which you are aware of
ii. Give your ratings to technologies
iii. Add HackerRank/HackerEarth technology/related technology star ranking in your resume
iv. While listing technologies sequence is important. For sequence, below points are important
1. Difficulty/Current trend of technology
5|Page
2. Your much you are prepared for that technology (most prepared technology at top)
3. Which technologies are required for the company you are applying (Required technologies at
top)
h. Project Details
i. Please ensure below points before adding project in resume
1. It is relevant to the position you are applying
2. You have done that project by your self
3. You have source code in your laptop
4. You are ready with the presentation of the same project
5. You have ER diagram of the same with you
6. You are clearly aware about the project flow
7. You have hosted that project on AWS or related cloud service (Optional but recommended)
ii. What to mention in resume about project?
1. Project Title (Title should clearly indicate the project idea)
2. Technologies used in project
3. Short description (1 to max 2 liner description)
4. Your role in the project (In case if it is group project)
5. Host that project on AWS and add QR code of AWS url in resume
i. Personal Details(Optional)
j. Achievements and awards (Try to keep it related to the position you are applying)
i. Use of digits is recommended. For e.g 1st rank in Java coding among 500 participants
k. Interest or Hobbies (Try to keep it related to the position you are applying)
5) General Guidelines
a. Prepare a strong linkedin profile and ask connections to recommend you for your technical skills
b. Keep an attention on font and alignment
i. Font should be professional
ii. All the headers must of same font and size
c. Read your resume at least 5 times before sending to avoid typo
d. Before sending resume to any company, do study of that company and Job description in detail, then
modify your resume accordingly, specially skills, technologies and hobbies and then send it.
e. Don‟t use too much colors. Background color should not be dark. It becomes difficult to read
f. Avoid to use sentences in entire resume except Objective. Use points instead of sentences
g. Ensure there is not any blank page in your resume
h. After preparing entire resumes, read it as if you are an interviewer and ask yourself, will you hire
yourself?

6|Page
Topic: Read Values from User

1) Scanner Class
2) Buffered Reader

Assignment
Scan all datatypes from user using above two classess

7|Page
Topic: Control Statements Part 1

SUb-Topics:
1. Types of Control statements
1. Conditional Statements
2. Iterations
3. Jumps
2. IntroDUCtion to Conditional Statements
3. Conditional statements:
A. If
B. If-else
C. Nested if-else
D. If-else if
E. Switch
F.
4. Jumps
1. Continue;
2. Break;
3. Return;
5. Ternary operator (String result = (marks > 40) ? "pass" : "fail";)
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1. How to accept different types of data using Scanner class.
2. Write a program to input a number from the user and display the corresponding day of the week.
(using if else if and switch) (Variations)
3. Write a program to input basic salary of an employee and calculate its Gross salary according to following:
(Variations)
Basic Salary <= 10000: HRA = 20%, DA =80% Basic Salary <= 20000 : HRA = 25%, DA=90% Basic Salary >
20000 : HRA = 30%, DA =95%
4. Consider a situation below of the electricity unit charges. Now input electric units by the user and calculate total
electricity bill according to the given condition. (Variations)
For first 50 units Rs. 0.50/unit For next 100 units Rs.0.75/unit For next 100 units Rs. 1.20/unit For unit above 250
Rs.1.50/unit
An additional surcharge of 20% is added to the bill
(I/P: 30 O/P:18. i/p 130 o/p: 102. i/p 230 o/p 235.2)
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Write a program to display maximum among three numbers. (Variations)
2) Write a program to display whether a number is even or odd.
3) Write a program to display whether a number is negative, positive or zero.
4) Write a program to display maximum number and minimum number between two numbers.
5) Write a program to input an alphabet and display whether it is a vowel or a consonant.
6) Write a program to display whether a character is an uppercase or lowercase alphabet. (Variations)
7) Write a program to display whether the triangle is equilateral, isosceles or scalene triangle.
8) Write a program to display and calculate profit or loss by a suitable example.
9) Write a program to develop a simple calculator application and perform some basic operations (Variations)
10) Write a program to display if a character is an alphabet, number or special character.
11) Write a program to display if the entered year is a leap year or not.
12) Write a program to input marks of five subjects by the user. Now calculate sum and percentage of the marks.
Find the grade according to following: (Variations)
a. Percentage >= 90% : Grade A
8|Page
b. Percentage >= 80% : Grade B
c. Percentage >= 70% : Grade C
d. Percentage >= 60% : Grade D
e. Percentage >= 40% : Grade E
f. Percentage < 40% : Grade F

Aptitude
Time And Distance
1. A person crosses a 600 m long street in 5 minutes. What is his speed in km per hour?
A.3.6 B.7.2 C.8.4 D.10
2. An aeroplane covers a certain distance at a speed of 240 kmph in 5 hours. To cover the same distance in 1 hours,
it must travel at a speed of:
A.300 kmph B.360 kmph C.600 kmph D.720 kmph
3. If a person walks at 14 km/hr instead of 10 km/hr, he would have walked 20 km more. The actual distance
travelled by him is:
A.50 km B.56 km C.70 km D.80 km
4. A train can travel 50% faster than a car. Both start from point A at the same time and reach point B 75 kms away
from A at the same time. On the way, however, the train lost about 12.5 minutes while stopping at the stations.
The speed of the car is:
A.100 kmph B.110 kmph C.120 kmph D.130 kmph
5. Excluding stoppages, the speed of a bus is 54 kmph and including stoppages, it is 45 kmph. For how many
minutes does the bus stop per hour?
A.9 B.10 C.12 D.20

Interview QUEstions:
1) What are control statements?
2) What are conditional statements?
3) Explain different types of conditional statements.
4) What is the difference between if else if and switch?
5) Explain the use of break.
6) What is ternary operator? Give an example.
7) What are called Decision statements in Java?
8) How will you legally define "if else" statement. Give an example.
9) What do the break and continue statements do?

9|Page
Topic: Control Statements Part 2

SUb-Topics:
1) Iterations
A. While
B. Do-while
C. For
C/W Assignment:
Tip: Trainers will assist for these questions.
1) Write a program to display the Fibonacci series.
2) Write a program to calculate and print the power of a number i.e a2 =a*a.
3) WRITE A PROGRAM to print following Pattern
*****
****
***
**
*
4) WRITE A PROGRAM to print followingPattern
1 2 3 45
2345
345
45
5
45
345
2345
1 2 3 45
5) WRITE A PROGRAM to print:

6) Write a program which prints 33 to 999. The numbers should be displayed as:
i. For multiples of 3 print "PINK" instead of the number

ii. For the multiples of five print "YELLOW".

iii. For numbers which are multiples of both three and five print "PINK &YELLOW".

Also print count of how many times “PINK” was printed, “YELLOW” was printed and “PINK &
YELLOW “was printed.

H/W Assignment:
Tip: Trainers will not assist for these questions.
1) Write a program to display 1 to 10 by implementing different loops.
2) Write a program to display table of a number.
3) Write a program to find if given number is prime or not.
10 | P a g e
4) Write a program to find factorial of a number.
5) Write a program to count number of digits of a number. (Variations)
6) Write a program to find sum of all digits of a numberentered by the user. (Variations)
7) Write a program to display even and odd numbers between a range entered by the user. (Variations)
8) Write a program to check and display if a given number is palindrome or not. (Variations)
9) Write a program to display elements between 100 to 200 (both numbers excluded) ending with seven. {Hint: output-
107,117,127….}(Variations)
10) Write a menu driven program to find all prime, even and odd numbers between 1 to 100
(Variations)
11) Write a program to print following Pattern

*
**
***
****
*****
12) Write a program to generate a followingtriangle.
1
12
123
1234
12345
13) Write a program to print the following pattern:.
1
22
333
4444
55555
14) Write a program to print following Pattern

1
21
321
4321
54321

15) Write a program to print following Pattern


1
23
456
7 8 9 10
11 12 13 14 15

11 | P a g e
16) Write a program to print following Pattern

10101
01010
10101
01010
10101
17) Write a program in Java to print the Floyd'sTriangle.
1
01
101
0101
10101

18) Write a program to generate following pattern.


*
***
*****
*******
*********
*******
*****
***
*
19) Write a program to print following Pattern
1
10
101
1010
10101

20) Write a program to display the pattern


1
212
32123
4321234
21) Given a number, the task is to check if it is Kaprekar number or not. A Kaprekar number is a
number whose square when divided into two parts and such that sum of parts is equal to the original number.
22 Write a program to print the first 15 numbers of the Pell series. In mathematics, the Pell numbers are an infinite
sequence of integers. The sequence of Pell numbers startswith 0 and 1, and then each Pell number is the sum of
twice the previous Pell number and the Pell number before that.: The first few terms of the
sequence are : 0, 1, 2, 5, 12, 29, 70, 169, 408, 985, 2378, 5741, 13860,… (Feb
Monthly).
23 Write a program to check whether a number is a Harshad Number or not.
In recreational mathematics, a harshad number in a given number base, is an integer that is divisible by the sum
of its digits when written in that base.
Example: Number 200 is a Harshad Number because the sum of digits 2 and 0 and 0 is 2(2+0+0) and 200 is
divisible by 2. Number 171 is a Harshad Number because the sum of digits 1 and 7 and 1 is 9(1+7+1) and 171 is
divisible by 9.(Jun Monthly).
24 Write a program to display the following pattern
1
12
123
1234
12 | P a g e
12345
123456
1234567
123456
12345
1234
123
12
1

26. (Samadhan Patil Nov 2020)


Aptitude:
Height And Distance
1. Two ships are sailing in the sea on the two sides of a lighthouse. The angle of elevation of the top of the
lighthouse is observed from the ships are 30° and 45° respectively. If the lighthouse is 100 m high, the distance
between the two ships is:
A.173 m B.200 m C.273 m D.300 m
2. A man standing at a point P is watching the top of a tower, which makes an angle of elevation of 30° with the
man's eye. The man walks some distance towards the tower to watch its top and the angle of the elevation
becomes 60°. What is the distance between the base of the tower and the point P?
A.43 units B.8 units C.12 units D.Data inadequate E.None of these
3. The angle of elevation of a ladder leaning against a wall is 60° and the foot of the ladder is 4.6 m away from
the wall. The length of the ladder is:
A.2.3 m B.4.6 m C.7.8 m D.9.2 m
4. An observer 1.6 m tall is 203 away from a tower. The angle of elevation from his eye to the top of the tower is
30°. The height of the tower is:
A.21.6 m B.23.2 m C.24.72 m D.None of these
5. From a point P on a level ground, the angle of elevation of the top tower is 30°. If the tower is 100 m high, the
distance of point P from the foot of the tower is:
A.149 m B.156 m C.173 m D.200 m

Interview Questions:
1) What are different types of loops?
2) What is the difference between while and do-while loop?
3) What are the looping constructs in Java?
4) Can you create a 'for 'loop without any conditional expressions?

13 | P a g e
Topic: OOPs

SUb-Topics:
2) IntroDUCtion
3) Classes &Objects
4) Creation of class and conventions for creating a class
5) Elements of classes
6) Local, instance and static variables
7) Creating objects
8) IntroDUCtion to OOPs methodologies
9) Wrapper classes

C/W Assignment:
Tip:Trainers will assist for these questions.
1) Write a program to display how to create a class and create different elements of a class (data members and
member functions etc).Also create objects of that class for accessing different elements to explain the concept of
classes and objects.
2) Create a class AdditionDemo having 3 instance variables number1 ,number2 and result. (Variations)
1) Create 4 methods as a) addition b) subtraction c) multiplication
d) division.
2) Calculate different operations as per the methods determined above. Create objects of AdditionDemo from main
method of another class Addition.
3) Write a program to show the implementation and use of local, instance and static variables in different context.
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Let us Assume and do the programming: An organization provides Diwali bonus of 35% to their employees. If the
year of service of that employee is more than 5 years and gives Diwali bonus of 15% to the employees if the year of
service is less than 5 years. Now Create a class and its respective methods to enter the data from the user and
calculate total salary of the employee (Variations)
2) Assume another company which is a laptop manufacturer company needs to develop
laptopswhich does the following: On unlocking thescreen it will display a “WELCOME” message first, After “
welcome “ message displays →
“Enter Option:”
1. Add-1
2. Subtract-2
3. Multiply-3
4. Quit-4
The user should be allowed to enter an option. If the user enters 1, a message needs to be displayed, “Enter two
numbers to be added”.
a. The user should be allowed to enter two numbers (In two separate lines).
b. Based on the numbers entered, the program should add and display the result as below
c. “The result is<result>”
d. After the result is displayed, the program should loop back and ask for the next menu entry. If the user enters 4, the
program should quit. (The program needs to be executed and do either one of the options until the kid enters
theoption4) (Variations)
Aptitude:
Time And Work
1. A can do a work in 15 days and B in 20 days. If they work on it together for 4 days, then the fraction of the work
that is left is :
A. 1/4 B. 1/10 C. 7/15 D. 8/15
2. A can lay railway track between two given stations in 16 days and B can do the same job in 12 days. With help of
C, they did the job in 4 days only. Then, C alone can do the job in:
14 | P a g e
A. 91days 5 B. 92days 5 C. 93days 5 D.10
3. A, B and C can do a piece of work in 20, 30 and 60 days respectively. In how many days can A do the work if he is
assisted by B and C on every third day?
A.12 days B.15 days C.16 days D.18 days
4. A is thrice as good as workman as B and therefore is able to finish a job in 60 days less than B. Working together,
they can do it in:
A.20 days B. 221days 2 C.25 days D.30 days
5. A alone can do a piece of work in 6 days and B alone in 8 days. A and B undertook to do it for Rs. 3200. With the
help of C, they completed the work in 3 days. How much is to be paid to C?
A.Rs. 375 B.Rs. 400 C.Rs. 600 D.Rs. 800
Interview QUEstions:
1) What is the difference between object oriented programming language and object based programming language?
2) What are the Oops methodologies?
3) What is a Class?
4) What is an Object?
5) What is Scanner class?
6) What is new?
7) What is the purpose of wrapper classes?
8) What are the wrapper classes available in Java?
9) What do you mean by autoboxing and auto-unboxing?

15 | P a g e
Topic: Access Modifiers

SUb-Topics:
1) IntroDUCtion to access modifiers
2) PUBlic
3) Private
4) DefaULt
5) Protected
C/W ASSIGNMENTS:
1. Problem Statement:
2. Follow the instRUCtions:
a) Create a class EmployeeDemo
b) Create 4 variables with the modifier as
emp_id(protected),emp_name(pUBlic),emp_salary(private),emp
_dept(deaUlt).
c) Create 4 methods with the signatUREs as
PUBlic void doPUBlic(),defaUlt void doDefaULt(),protected void doProtected(),private void d
d) Initialize these variables by entering data from the User and display the data of the employee.
e) Access all the variables from these 4 methods to check the visibility and scope of variables.
f) Perform the above tasks in same package,same class and in different package in different class.

Aptitude:
Simple Interest

1. A sum of money at simple interest amounts to Rs. 815 in 3 years and to Rs. 854 in 4 years. The sum is:
A.Rs. 650 B.Rs. 690 C.Rs. 698 D.Rs. 700
2. Mr. Thomas invested an amount of Rs. 13,900 divided in two different schemes A and B at the simple interest
rate of 14% p.a. and 11% p.a. respectively. If the total amount of simple interest earned in 2 years be Rs. 3508,
what was the amount invested in Scheme B?
A.Rs. 6400 B.Rs. 6500 C.Rs. 7200 D.Rs. 7500 E.None of these
3. A sum fetched a total simple interest of Rs. 4016.25 at the rate of 9 p.c.p.a. in 5 years. What is the sum?
A.Rs. 4462.50 B.Rs. 8032.50 C.Rs. 8900 D.Rs. 8925 E.None of these
4. How much time will it take for an amount of Rs. 450 to yield Rs. 81 as interest at 4.5% per annum of simple
interest?
A.3.5 years B.4 years C.4.5 years D.5 years
5. Reena took a loan of Rs. 1200 with simple interest for as many years as the rate of interest. If she paid Rs. 432
as interest at the end of the loan period, what was the rate of interest?
A.3.6 B.6 C.18 D.Cannot be determinedE.None of these

Interview Questions:

1. What are the possible access modifiers for a constructor?


2. What are the valid modifiers of an inner class?

16 | P a g e
Topic: Methods

SUb-Topics:
1) IntroDUCtion
2) StRUCtURE of method
3) Non-parameterised method with no retURN Type
4) Non-parameterised method with retURN Type
5) Parameterised method with no retURN Type
6) Parameterised method with retURN Type
7) Conventions in methods
8) Method overloading
9) Static methods
C/W Assignment:
Tip:Trainers will assist for these questions.

1) Write a program to create a class Student and do the following:


 Create a method to input data (rollNo, Name, contactNo, Total marks)
 Create another method to display the data of Student class.
 Create object of Student class and access these methods main method of a new class – StudentDemo.java.
2) Write a program to show method overloading by performing following steps:
Create a class to print the area of a square, a rectangle and a triangle. The class has3 methods with the same name
but different number of parameters. The method for printing area of rectangle has two parameters which are
length and breadth respectively, for printing the area of triangle method has 3 parameters and while the other
method for printing area of square has one parameter which is side of square. (Variations)
3) Write a program and perform the following steps: Create a class AccountManagement containing following
methods: insertData() to insert account details of customers, displayData() to display account details
depositAmount() to deposit amount of customer
withdrawAmount() to withdraw amount accountBalance() to checkbalance in customer‟s account.
The methods should execute as per their specification.
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Write a program and perform the following: (Variations)
a) Define class “ROOM”.
b) Define data Members as :
i. Length
ii. Width
iii. Height
c) Define constructors as per requirement.
d) Define methods as :
i. Float whiteWashingArea() to compute the area to be whitewashed.
ii. Int whiteWashingCost() to compute the cost of whitewashing at the rate of Rs.80 per sq.ft
iii. Int flooringCost() to compute the cost of flooring at the rate of Rs200/-sq.ft for geometric flooring and at the rate
of Rs100 /- sq.ft for cement flooring.
iv. Test this class by creating an object for the class Room and compute the cost for respective methods.
2) Create one class Cube having instance variables (height, width, depth). Add one method to calculate volume of
the cube with return type void. (Variations)
3) Write a progam to create Calculator class which have methods addition(int num1,int

17 | P a g e
num2),subtraction(int num1,intnum2), multiplication(int num1, int num2), division(int num1, int num2) with
return type double .Create a menu driven program and do perform these operations of a calculator by creating an
object of this class and execute these methods from main method of another class. (Variations)
4) Define class “Triangle”.
a) Define data Members as :
i. Side1
ii. Side2
iii. Side3
iv. Angle1,Angle2,Angle3
b) Define constructors as per requirement.
c) Define methods as :
i. trianglePerimeter() ii.triangleArea() iii.isosceles() iv.equilateral() v.rightAngled()
Test this class by creating an object for the class triangle. (Variations)
5) Create 4 overloaded methods for “test ()” and invoke all versions of the overloaded methods.
a. Create another class Overload.java which has a main method to call the overloaded methods inOverloadDemo.java
(Variations)
6) Perform the following: Class Name:-Calculator
Method Name:- CalculateSum
Method Description:-Calculates the sum of two Numbers Argument:-int number1, int number Return Type:- int
– Sum
Logic:-Calculate the sum of the two numbers number1 and number2 and return the sum.

Method Name:-Calculate Difference


Method Description:-Calculates the difference between two numbers Argument:-int number1 , int number2
Return Type:-int – difference
Logic:-Calculate the difference between the numbers number1 and number2 and return the difference.
(Variations)

7) Perform thefollowing:
Class Name:-MessagePrinter
Method Name:-printMessage Method Description:-Prints the message Argument:- String name Return Type:-
Void
Logic:-Print the message using the console output command.
8) Write a program to do the following: Create a class “Square”.
Create a method “calculateArea”, with length as an argument,
Now calculate the area and return area. Create another class “SquareDemo”in which main method should invoke
the Square class method by passing a value for the length. (Variations)
Aptitude
Compound Interest
1. A bank offers 5% compound interest calculated on half-yearly basis. A customer deposits Rs. 1600 each on
1st January and 1st July of a year. At the end of the year, the amount he would have gained by way of interest is:
A.Rs. 120 B.Rs. 121 C.Rs. 122 D.Rs. 123
2. The difference between simple and compound interests compounded annually on a certain sum of money for
2 years at 4% per annum is Re. 1. The sum (in Rs.) is:
A.625 B.630 C.640 D.650
3. There is 60% increase in an amount in 6 years at simple interest. What will be the compound interest of Rs.
12,000 after 3 years at the same rate?
A.Rs. 2160 B.Rs. 3120 C.Rs. 3972 D.Rs. 6240 E.None of these
4. What is the difference between the compound interests on Rs. 5000 for 1 years at 4% per annum compounded
yearly and half-yearly?
A.Rs. 2.04 B.Rs. 3.06 C.Rs. 4.80 D.Rs. 8.30
5. The compound interest on Rs. 30,000 at 7% per annum is Rs. 4347. The period (in years) is:
A.2 B.2.5 C.3 D.4

18 | P a g e
Interview QUEstions:

 What are methods?


 What is meant by MethodOverloading?
 What are Method Overloading rules?
 Is java Pass by Reference or Pass byValue?

19 | P a g e
Topic: Constructors

SUb-Topics:
1) IntroDUCtion
2) StRUCtURE and Use of constRUCtors
3) Difference between methods &constRUCtors
4) Parameterized constRUCtors
5) Non-Parameterized constRUctors
6) ConstRUCtor overloading
7) Use of this
8) Inner Classes
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Create a class Vehicle with member variables: String Color, int wheelCount ,int gearsCount. Initialize these
variables by giving values. Create another constructor which takes 2 arguments(Color and gearsCount), calls the
default constructor using this () and has a SOP in it displaying the color, number of wheels in the Vehicle and
number of gears in the vehicle. In main method, create an object of type Vehicle by using default constructor.
Note the output. Create another object of type Vehicle by using the parameterized constructor. Note the sequence
of data indicating that inner most constructors are called first. (Variations)
2) Create a class Rectangle with two instance variables: length and width. Create a constructor initialing the instance
variables.Subsequently, two objects of this class are created and then the methods rectangleArea() and
rectanglePerimeter() are invoked. (Variations)

3) Create a class Test with constructors to initialize the variables and methods to perform the following tasks. Give
appropriate arguments to methods. Methods should perform following programs:
a. Even odd
b. Factorial of a number using do-while loop. c.Find sum of all digits of a number
4) Write a demo program for different types of Inner Classes.
5) Write a program to illustrate the concept of copying objects using constructors
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Create class Employee with constructors (default and parameterized), methods (1 with return type (calculating
salary), 1 without return type (displaying employeedata)).
2) Create a class named 'Rectangle 'with two data members- length and breadth and a method to calculate the area
which is 'length*breadth'. The class has three constructors which are:
1 - having no parameter - values of both length and breadth are assignedzero.
2 - Having two numbers as parameters - the two numbers are assigned as length and breadth
respectively.
3 - Having one number as parameter - both length and breadth are assigned that number.
Now, create objects of the 'Rectangle' class having none, one and two parameters and print their areas.
3) Create a class Bank .Initialize an instance variable ” amount” with an initial amount of Rs.5000 and assume you
have to add some more amount to it. Now make two constructors of this class as follows:
1 - without any parameter - no amount will be added to the Bank
2 - having a parameter which is the amount that will be added to Bank Create object of the
'AddAmount' class and display the final amount in Bank
4) Create a class named 'Programming'. While creating an object of the class, if nothing is passed to it, then the
message "I want to learn language" should be printed. If some String is passed it, then in place of " ” the name of
that String variable should be printed. For example, while Creating object if we pass "Java", then " I want to
learn Java" should be printed.

5) Create a class ShapeCircle.java and do the following steps:


a) Add an instance float variable pi and create two overloaded constructors. Constructor 1- with a float argument
20 | P a g e
name radius. The constructor should initialize the class variable radius with the method argument radius. The
instance variable and the method argument should be named same as “radius”.
b) Constructor 2- with two float arguments radius and pi. Default the class pi value to
3.5 and set the instance variable with the radius method argument.
c) The constructor “constructor 2” should be invoked from a main method from class, Area.java.
In Circle.java, invoke the Constructor 2 created in the previous step from Constructor 1.
6) Create two methods and calculate area and circumference of a Circle In the Circle.javaclass, create two methods
as listed below
a. Method 1 – calculate CircleArea should accept the float radius as parameter and
calculate the area (pi*r*r). It should return the result value to the main method where it should be printed in
theconsole.
b. Method 2 – calculate Circumference should accept float radius as parameter and
calculate the circumference (2 * pi * r). It should return the result value to the main method where it should be
printed in theconsole.
Call these two methods from the main method in Circle.java by passing appropriate parameters.
7) Write a program to demonstrate different types of Inner Classes .Create class College as a Outer Class and
Department as a Inner Class. Use appropriate Variables and Methods.

Aptitude
Profit And Loss
1. Alfred buys an old scooter for Rs. 4700 and spends Rs. 800 on its repairs. If he sells the scooter for Rs. 5800,
his gain percent is:
A. 44% 7 B. 55% 11 C.10% D.12%
2. The cost price of 20 articles is the same as the selling price of x articles. If the profit is 25%, then the value of
x is:
A.15 B.16 C.18 D.25
3. If selling price is doubled, the profit triples. Find the profit percent.
A. 662 3 B.100 C. 1051 3 D.120
4. In a certain store, the profit is 320% of the cost. If the cost increases by 25% but the selling price remains
constant, approximately what percentage of the selling price is the profit?
A.30% B.70% C.100%D.250%
5. A vendor bought toffees at 6 for a rupee. How many for a rupee must he sell to gain 20%?
A.3 B.4 C.5 D.6

Interview QUEstions:
1) What are constructors?
2) What is the difference between methods andconstructors?
3) Explain default constructors.
4) Can a class have multiple constructors?
5) What are the rules to define a constructor?
6) Explain the use of „this‟ keyword.
7) What is an Inner class?
8) What are the types of classes available in Java?
9) Write two lines of code which will instantiate the inner class from the outerclass.
10) How will you define a constructor? Give an example.
11) What is the benefit of reference variable? Give an example.
12)

21 | P a g e
Topic: Inheritance

SUb-Topics:
1) IntroDUCtion
2) Single inheritance
3) MULtilevel inheritance
4) MULtiple inheritance
5) Hierarchical inheritance
6) Hybrid inheritance
7) Use of SUper,final

C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Create a class Test1 with two instance variables num1 and num2.Create another class Test2 which is inheriting
Test1.Apart from inheriting class Test1,Test2 declares another variable num3.Here an object of class Test2 will
have the instance variables num1 and num2due to the concept of inheritance. Within the main() of class
Test2Demo create an object of class Test2 and assign the values to the instance variables and display them
displaying the concept
of inheritance.
2) Write a program displaying different types of inheritance.
3) Write a program to do the following as per steps:
a) Create a class Test.
i. Create a method display1() which prints a message “GOOD MORNING”.
ii. Create another method display2() which prints a message “GOOD AFTERNOON”.
b) Create new class TestingInheritance which inherits class Test.
i) Create a method display3() which prints a message “GOOD EVENING”.
c) Create a class TestingDemo
i) Create object of class TestingInheritance and call all of the methods inherited from class
Test illustrating the concept of inheriting methods in a class.
4) Using the above example illustrate the concept of method overriding.
5) Illustrate the concept of super and final using suitable examples.
6) Show use of Multi Level Inheritance in case of library Management System (FebMonthly).

H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.

1) Create a class named „Worker‟ having the following members: Sname, Sage, Sphone number ,Saddress,
Ssalary.It also has a method named 'displaySalary' which displays the salary of the members. Two classes
'Employee' and 'Manager' inherit the „Worker‟ class. The 'Employee' and 'Manager' classes have data members
'Work specialization' and 'department' respectively. Now, assign name, age, phone number, address and salary to
an employee and a manager by making an object of both of these classes and print the same.
2) Define a class named Vehicle as described below:
i) Data Members:
a. vehicle name
b. vehicle model number
c. vehicle price
d. service station name
ii) Methods:
a. Constructor
b. Display() method to display all the details of class Vehicle .
iii) Define another class named Bike that extends the class Vehicle.
22 | P a g e
a. Data Members: discountRate
b. Constructor
c. Methods:display() to display bike name,bike model number,bike price,service station name,discount rate.
d. Discount() method to compute the discount.

23 | P a g e
iv) Create an object for the class Bike and test it.
3) Define a class named Square as shown below:
i) Data Member: side
ii) Methods: area() iii)Constructor.
iv) Define another class Rectangle that extends class Square
a. Data Member: length,breadth
b. Constructor.
c. Methods: area()
v) Define one more class named Triangle that extends the class Rectangle
a. Data Member: side1,side2,side3
b. Constructor
c. Methods: area()
vi) Create objects for the classes Square,rectangle and Triangle.Test them.

4) Test Examples of Multilevel Inheritance.


5) WRITE A PROGRAM for Department class having departmentName and HOD name as instance variables,a
constructor to initialize the variables and showDepartmentDetails() to display the details.Create StaffMember
class having MemberName and MemberQualification as instance variables.Create the constructor and
showstaffMemberDetails() method to display the details.
Create the objects for the class “staffMember” which extends department andTest them.

6) Explain one example of hierarchical Inheritance.

7) Write a program to show the implementation of finalkeyword.

8) Problem Statement on below scenario


a. Create a class Employee with following Instance variables and data types

Instance Variable Data Type


employeeId Long
employeeName String
employeeAddress String
employee Phone Long
basicSalary Double
specialAllowance double default value- 250.80
Hra double default value- 1000.50
b. Create an overloaded constructor in the employee class, which takes the below constructor parameters and
initializes them to their respective instance variables.
Constructor parameter Instance Variable
Id employeeId
Name employeeName
Address employeeAddress
Phone employeePhone
BasicSalary BasicSalary
c. Create a method calculateSalary in which, salary needs to be calculated as below. salary = basicSalary +
(basicSalary *specialAllowance/100) + (basicSalary
*hra/100); The calculated salary shouldbedisplayed in theconsole. NOTE: salary is a local variable.
d. Create the sub classes Manager and Trainee with base class Employee. Create overloaded constructors which
takes the below parameters and initializes them to the respective variables in the super class
Constructor parameter Instance Variable
Id employeeId
Name employeeName
Address employeeAddress
Phone employeePhone
27 | P a g e
Salary basicSalary

e. Create a class “TrainersActivity.java” with a main method which performs the above functions
9) Problem Statement on above scenario
a) Add a method called calculateTransportAllowance in Employee class which shouldcalculate the transport
allowance by calculating 10% (default allowance)ofthe salary. Print the salary after calculating.
transportAllowance = 10/100*basicSalary.
b) Fora manager, the transportation allowance is 15%ofthe basic salary. So override the calculate Transport
Allowance method in Manager class which should calculate the transport allowance as 15%ofthe base salary.
Print the salary after calculating transport Allowance = 15*basicSalary /100.
c) Fora trainee, the transport allowance is same as the default allowance; the method calculate Transport Allowance
in the base class can beused.
d) Invoke the calculate Transport Allowance for the manager and trainee class in the main method
ofTrainersActivity.java.

Aptitude
Partnership
1. A and B invest in a business in the ratio 3 : 2. If 5% of the total profit goes to charity and A's share is Rs. 855,
the total profit is:
A.Rs. 1425 B.Rs. 1500 C.Rs. 1537.50 D.Rs. 1576
2. A, B and C jointly thought of engaging themselves in a business venture. It was agreed that A would invest
Rs. 6500 for 6 months, B, Rs. 8400 for 5 months and C, Rs. 10,000 for 3 months. A wants to be the working
member for which, he was to receive 5% of the profits. The profit earned was Rs. 7400. Calculate the share of B
in the profit.
A.Rs. 1900 B.Rs. 2660 C.Rs. 2800 D.Rs. 2840
3. A, B and C enter into a partnership in the ratio : : . After 4 months, A increases his share 50%. If the total
profit at the end of one year be Rs. 21,600, then B's share in the profit is:
A.Rs. 2100 B.Rs. 2400 C.Rs. 3600 D.Rs. 4000
4. A, B, C subscribe Rs. 50,000 for a business. A subscribes Rs. 4000 more than B and B Rs. 5000 more than C.
Out of a total profit of Rs. 35,000, A receives:
A.Rs. 8400 B.Rs. 11,900 C.Rs. 13,600 D.Rs. 14,700
5. Three partners shared the profit in a business in the ratio 5 : 7 : 8. They had partnered for 14 months, 8
months and 7 months respectively. What was the ratio of their investments?
A.5 : 7 : 8 B.20 : 49 : 64 C.38 : 28 : 21 D.None of these

Interview QUEstions:
1) Explain difference between single and multilevel inheritance.
2) Why java does not support multiple inheritance?
3) What is final?
4) What is hierarchal inheritance?
5) What do you understand by the keyword super?
6) What are the benefits of inheritance?
7) Write a code that uses inheritance concept.
8) What are the types of inheritance relationships
9) Is it possible to extend more than one class? State the reasons.
10) How does a subclass call a constructor defined. in its super class?
11) In what order are constructors called in a: class hierarchy?.

28 | P a g e
Topic: Containment
SUBTOPICS:

1) Introduction
2) Using Accessors and Mutators
3) Using constructors
4) POJO
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1. Write a program to illustrate the concept of containment:
a) Create a class Address with the following:
i) Data Members: streetNo.,city, state, country.
ii) Constructor with arguments to initialize the variables.
b) Create class Person with the following:
i) Data Members:PName, PAdhaarNo.,PJobName,PJobId,PJobLocation
ii) Constructor with args to initialize the variables. iii)Create Address object as a member of
Person class.
iv)Create method displayPersonDetails() to display the details of person.
c) Create a class college
i) Data Members: collegeName,Address collegeAddress.
ii) Constructor with arguments to initialize thevariables
iii) Create method displayCollegeDetails() to display the details of college
d) Create a class Staff
i) Data Members: employeeName,Address employeeAddress.
ii) Constructor with arguments to initialize the variables
iii) Create method displayStaffDetails() to display the details of staff
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.

1. Write a program to illustrate the concept of containment:


a) Create a class Author with the following:
i) Data Members: authorName,age,place.
ii) Constructor with arguments to initialize thevariables. iii)Use getter methods to get values.
b) Create class Book with the following:
i) Data Members:name,price,Author author(object)
ii) Constructor with args to initialize the variables. iii)Create method showDetails() to
display the details.
2. Create a class Employee with int id and String name as member variables. Initialize these variables using getter
and setter methods by taking data from the user. Create object of this class and access these methods from the
main method of another class. Also provide different values to observe the changes.

Aptitude

Percentage

1. A batsman scored 110 runs which included 3 boundaries and 8 sixes. What percent of his total score did he
make by running between the wickets?
A.45% B. 455% 11 C. 546% 11 D.55%
2. Two students appeared at an examination. One of them secured 9 marks more than the other and his marks
was 56% of the sum of their marks. The marks obtained by them are:
A.39, 30 B.41, 32 C.42, 33 D.43, 34
29 | P a g e
3. A fruit seller had some apples. He sells 40% apples and still has 420 apples. Originally, he had:
A.588 apples B.600 apples C.672 apples D.700 apples
4. What percentage of numbers from 1 to 70 have 1 or 9 in the unit's digit?
A.1 B.14 C.20 D.21
5. If A = x% of y and B = y% of x, then which of the following is true?
A.A is smaller than B. B.A is greater than B C.Relationship between A and B cannot be determined.
D.If x is smaller than y, then A is greater than B. E.None of these

30 | P a g e
Topic: Abstraction& Interfaces
SUb-Topics:
1) IntroDUCtion
2) Abstract methods
3) StRUCtURE& need of abstract classes
4) Abstract classes
5) StRUCtURE& need of interfaces
6) Difference between abstract classes &interfaces
7) Extending Interfaces
8) Interface Java 8 featUREs.
9) Packages
10) Anonymous Class
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Define an abstract class named Shape that contains an empty method named numberOfSides().Define
three classes named Trapezoid, Triangle and Hexagon such that each one of the classes extends the class. Shape.
Each one of the classes contains only the method numberOfSides() that displays the number of given geometrical
figure.
Demonstrate how the trapezoid, triangle and hexagon classes can be instantiated and their methods can be tested.

2) Declare an abstract class Vehicle with an abstract method named numWheels().Provide the two subclasses Car
and Truck each one of which implements this method. Create instances of these two subclasses and demonstrate
the use of the numWheels() method.
3) Write a program to create and use classes from different Packages.

H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1. A VotingApp needs to develop an onlineapplication for two types of users, Adults and children. Both of these
users should be able to register an account. Any user who is less than 12 years of age will be registered as a child
and they cannot go for voting, whereas an adult can butonly once.
Note: In future, more users/roles might be added to the App where similar rules will been forced. Develop
Interfaces and classes for the categories mentioned above.
a. Create an interface VotingApp with the following methods declared
Method Name:
registerUser
requestVotingNumber

31 | P a g e
The methods in the Kids class should perform the following logic.
i. registerUser : if age < 12, a message displaying “You have successfullyregistered under Kids”
should be displayed in the console.
If(age>12), a message displaying, “You have not successfully registered” should be displayed in the console.
e. requestVotingNumber: if voting Type is “Kids”, a message displaying “Sorry cannot go for voting because Age
must be greater than 12 to vote” should be displayed in the console
The methods in the Adult class should perform the following logic.
i. registerUser : if age > 12, a message displaying“ You have successfully registered under an Adult”
should be displayed in the console.

If age<12, a message displaying, “You have not successfully registered under an Adult” should be displayed in
the console.
ii. requestVotingNumber: if voting Type is “Adult”, a message displaying “Your voting Id will be
generated within a day “should be displayed in theconsole.

else, a message displaying, “Oops, you are not” should be displayed in the console.
f. Create a class “VotingAppDemo.java” with a main method which performs the functions
2. WRITE A PROGRAM to create Package arithmetic having classes Addition, Subtraction, Division
,Multiplication with appropriate methods .Use this Classes outside the package.

Aptitude
Problems on ages

1. Father is aged three times more than his son Ronit. After 8 years, he would be two and a half times of Ronit's
age. After further 8 years, how many times would he be of Ronit's age?
A.2 times B. 2 1times 2 C. 2 3times 4 D.3 times
2. The sum of ages of 5 children born at the intervals of 3 years each is 50 years. What is the age of the youngest
child?
A.4 years B.8 years C.10 years D.None of these
3. A father said to his son, "I was as old as you are at the present at the time of your birth". If the father's age is 38
years now, the son's age five years back was:
A.14 years B.19 years C.33 years D.38 years
4. A is two years older than B who is twice as old as C. If the total of the ages of A, B and C be 27, then how old
is B?
A.7 B.8 C.9 D.10 E.11
5. Present ages of Sameer and Anand are in the ratio of 5 : 4 respectively. Three years hence, the ratio of their
ages will become 11 : 9 respectively. What is Anand's present age in years?
A.24 B.27 C.40 D.Cannot be determined E.None of these

Interview QUEstions:

1. What do understand by abstraction?


2. What are abstract classes and abstract methods?
3. Explain interfaces?
4. How multiple inheritances is achieved using interfaces?
5. What is the difference between abstract class and aninterface?
6. Does an abstract class contain non-abstract methods?
7. Can we use default when we override methods of an interface?
8. Can an abstract method have a body?
9. Write two lines of code and explain how you will implement an anonymous inner class.

32 | P a g e
Topic: Arrays

SUb-Topics:
1. IntroDUCtion
2. Declaration, initialization of array
3. Single dimensional array
4. for each
5. Operations on array: searching, sorting
6. Two-dimensional array
7. Array of objects
C/W Assignment:
Tip:Trainers will assist for these questions.
1. Write a program to calculate sum and average of arrayelements(Variations)
2. Write a program to perform binary search.
3. Write a program sort array elements in using selection sort, merge sort.
4. Write a program sort array elements in using insertion sort.
5. Write a program to arrange the elements of an given array of integers where all positive integers appear before all
the negative integers. (Variations)
6. Write a program to find transpose of a matrix .
7. Number of unique pairs in an array. Give nan array of N elements, that ask is to find all the unique pairs that can be
formed using the elements of a given array.(MarchMonthly). (Variations)
Examples: Input: arr[] = {1, 1, 2}
Output: 4
(1, 1), (1, 2), (2, 1), (2, 2) are the only possible pairs.

Input: arr[] = {1, 2, 3}


Output: 9
8. Write a program to implement stack methods using array. (Jun Monthly) (Variations)
9. Write a program to implement queue methods using array. (Shankar Jadhav Nov 2020)(Variations)

H/W Assignment:
Tip:Trainers will not assist for these questions.
1) Write a program to find the index of an array element.
2) Write a program to test if an array contains a specific value (Variations)
3) Write a program to remove a specific element from an array (Variations)
4) Write a program to copy an array by iterating the array.
5) Write a program to find and display reverse of an array using third variable.

33 | P a g e
6) Write a program to find and display reverse of an array without using thirdvariable.
7) Write a program sort array elements in ascending order using bubble sort.
8) Write a program to find the second largest element in an array (Variations)

10) Write a program to find maximum element in a matrix. (Variations)


11) Write a program to remove the duplicate elements of a given array and return the new length of the array.
(Variations)

12) Write a program to put even and odd elements of array in two separate arrays. (Variations)
13) Write a program to test the equality of two arrays (Variations)

14) Write a program to print all the LEADERS in the array.


Note: An element is leader if it is greater than all the elements to its right side
15) Write a program to get the difference between the largest and smallest values in an array of integers. (Variations)
16) Write a program to replace 0‟s with 1‟s. e.g array is [0,1,0,1,0,1,0,1,0,1,0,1,0]. (Variations)
17) Write a program to separate even and odd numbers of an given array of integers. Put all even numbers first, and
then odd numbers. (Variations)

18) Write a program to display data in 2D array.

19) Write a program calculate the average of the inner elements of an array(Variations)

20) Write a program to print the addition of two matrices. (Variations)

21) Write a program to calculate the subtraction and multiplication of two matrices entered by the user.
22) Write a program to display outer elements of a matrix. i.e 2d array of size 6 x 6. (Variations)

23) Write a program to rotate an array to the left. (Variations)


24) Write a program to create Student class having rollno, name, marks. Create 10 objects
. Using Array of Objects display information of student who got highest marks . (Variations)
25) Given an integer array and size of subarray,find the first subarray with leasts average in single loop. Print first
index of subarray and average. (Mindstix) (Variations)
Method signature Find Firstsub(int arr[], int arr_len, int sub_arr_len)
{
//Your code
}
Example:
Input:
int arr={3,7,90,20,5,50,40}, k=3
Find Firstsub(arr,7 Output:
Index:3 Avg:25
26) Given 2 character arrays s1 and s2 and another empty character array s3.
Populate s3 by interleaving characters from both s1 and s1(Mindstix) (Variations)
Method signature
Void interleaved (char[] s1, char[]s2, char[]s1, int s1_len, int s2_len)
{
// Your Code
}
Example 1:
S1={„a‟,‟b‟,‟c‟,‟d‟};
S2={„w‟,‟x‟,‟y‟,‟z‟};
34 | P a g e
Output:
S3={„a‟,‟w‟‟b‟,‟x‟‟c‟,‟y‟,‟d‟,‟z‟}.

Example 2:
S1={„a‟,‟b‟,‟c‟,‟d‟,‟e‟,‟f‟,‟g‟};
S2={„w‟,‟x‟,‟y‟,‟z‟};
Output:
S3={„a‟,‟w‟‟b‟,‟x‟‟c‟,‟y‟,‟d‟,‟z‟ ,‟e‟,‟f‟ ,‟g‟}.

Example 3:
S1={„a‟,‟b‟,‟c‟,‟d‟};
S2={„w‟,‟x‟,‟y‟,‟z‟ ,‟e‟,‟f‟,‟g‟};
Output:
S3={„a‟,‟w‟‟b‟,‟x‟‟c‟,‟y‟,‟d‟,‟z‟ ,‟e‟,‟f‟ ,‟g‟}.
27) Write a program or function to find saddle point of a matrix. Your program should take input matrix from
the user, display the matrix and find the saddle point of that matrix. Saddle point of a matrix is an element in the
matrix which is smallest in its row and largest in its column. A matrix can have many or no saddle points. For
example,

6 3 1
9 7 8
2 4 5
In this matrix, 7 is the saddle point. Because it is the smallest in its row (2nd row) and largest in its column (2nd
column).
28) Remove the elements of 2nd array from 1st array (if found multiple, remove only two)
Ex: input array int[] a= {1,1,1,1,1,2,2,3,4}; elements to remove int[] n= {1,2,4};
expected output: {1,1,1,3} (Harshada Dec 2020)
29) Write a program to find out count of triplets with sum smaller than given sum value. (Variations) Examples:
Array=[5,1,3,4,7] S=12.
Output :4
Explaination: Below are triplets with sum less than 12
(1,3,4),(1,3,5),(1,3,7),(1,4,5)

30) Write a program to find sum of diagonal elements of a matrix. (Variations)


31) Write a program of how to pass array as a parameter to method in java?
32) Write a program to take 10 integer inputs from user and print the number of positive numbers, number of
negative numbers, number of odd numbers number of even numbers (Variations)
33) Write a program to merge two arrays into third array. (Variations)
34) Find the minimum distance between 2 seeds( m and n) provided in an integer array arr[] of given length. Array
can contain duplicates and negative integers. Assume that both m and n are different and be present
inarr[].(Variations)
Method Signatue
FindMinDist(int arr[],int arr_length,int m,int n)
{
//your code here
}

Constraints:
Do not use any additional data structures. You may use as many as primitive variables.
35) Write a program to find all the unique triplets such that sum of all the three elements is equal to a specified
number.(April Monthly) (Variations).
35 | P a g e
Input-2.
Output- [[1,5,-4],[-2,5,-1]]
Reason: 1+5-4=2& -2+5-1=2 2 is Target ...
36) Write a program to Find unique Pair Of Integers in Array whose Sum is Given Number. (Variations) Given array
: [2, 4, 3, 5, 6, -2, 4, 7, 8, 9]
Given sum : 7
Integer numbers, whose sum is equal to value : (2, 5) (4, 3) (-2, 9) . .(April Monthly).
37) Sort array using only one loop.
38) Split array arr[] into strictly increasing and decreasing sequences in single loop and without changing the original
order. (Variations)
Method Signature void splitArray(int arr[]
{
//Your code goes here
}
Example 1 Input: aryl]_ [5, 1, 3, 6, 8, 2, 9, 0, 10]
Output: [1, 3, 6, 8, 9, 10] [5, 2, 0]
Example 2 Input: arr[j = [1, 2, 4, 0, 2]
Output: -1
//No such sequences possible.

Aptitude
Clock
1. An accurate clock shows 8 o'clock in the morning. Through how may degrees will the hour hand rotate when
the clock shows 2 o'clock in the afternoon?
A.144° B.150° C.168° D.180°
2. The reflex angle between the hands of a clock at 10.25 is:
A.180° B. 1921° 2 C.195° D. 1971° 2
3. A clock is started at noon. By 10 minutes past 5, the hour hand has turned through:
A.145° B.150° C.155° D.160°
4. A watch which gains 5 seconds in 3 minutes was set right at 7 a.m. In the afternoon of the same day, when the
watch indicated quarter past 4 o'clock, the true time is:
7 7 3
A.59 12 min 𝑝𝑎𝑠𝑡 3 B. 4 p.m. C. 58 11 min 𝑝𝑎𝑠𝑡 3 D. 2 11 min 𝑝𝑎𝑠𝑡 4
5. How much does a watch lose per day, if its hands coincide every 64 minutes?
8 5
A. 32 11 𝑚𝑖𝑛 B. 36 11 𝑚𝑖𝑛 C.90 min. D.96 min.
Interview QUEstions:

• What are arrays?


• What is one dimensional array?
• How to create and access elements in java?
• What are two dimensional arrays?
• What are applications of an array?
• What are advantages & disadvantages of arrays?

36 | P a g e
Topic: Strings

SUb-Topics:
1) IntroDUCtion
2) ImmUTable Strings
3) Methods of strings

C/W Assignment:
Tip:Trainers will assist for these questions.
1) Write a program to create strings using new and using literal.
2) Write a program to get the character at the given index within the String.
3) Write a program to compare two strings lexicographically.
4) Write a program to compare two strings lexicographically, ignoring casedifferences.
5) Write a program to concatenate a given string to the end of another string
6) Write a program to compare a given string to the specified character sequence.
7) Write a program to compare a given string to the specified stringbuffer.
8) Write a program to test methods of StringBuffer.
9) Write a program to test methods of StringBuilder.
H/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Write a program to create a new String object with the contents of a character array
2) Write a program to check whether a given string ends with the contents of another string.
3) Write a program to check whether two String objects contain the same data
4) Write a program to compare a given string to another string, ignoring case considerations.
5) Write a program to get the index of all the characters of the alphabet.
6) Write a program to get the last index of a string within a string.
7) Write a program to get the length of a given string.

37 | P a g e
8) Write a program to replace all the 'd' characters with 'f'characters.
9) Write a program to check whether a given string starts with the contents of another string.
10) Write a program to create a character array containing the contents of a string.
11) Write a program to convert all the characters in a string to lowercase.
12) Write a program to convert all the characters in a string touppercase.
13) Write a program to remove a specified character from a given string.
14) Write a program to test if a given string contains only digits
15) Write a program to return the sum of the digits present in the given string. If there is no digits the
sum return is 0.
16) Write a program to count and print all the duplicates in the input string.
17) Write a program to reverse every word in a string using methods.
18) Write a program to find the maximum occurring character in a string.
19) Write a program to print after removing duplicates from a given string.
20) Write a program to find Length of the longest substring without repeating characters.
21) Write a program to find the second most frequent character in a given string.
22) Write a program to trim any leading or trailing whitespace from a given string.
23) Write a program to find frequency of character in a string
24) Write a program to get lowest frequency of a character in a string.
25) Write a program to repeat each of the character twice in a given string.
26) Write a program to convert all the characters in a string tolowercase.
27) Write a program to delete all extra blank spaces in a string by the user.
28) Write a program to sort in ascending and descending order by length of the given array of strings.
29) Write a program to sort the array of String like dictionary (By Amol Botre April 2021)
30) Add 10 StringBuffer objects in an Array , Count no. Of Palindrome Strings, Display in Ascending
order such Strings
31) Exchange Cipher (String & char)This simple cipher exchanges 'A' and 'Z', 'B' and 'Y', 'C' and 'X',
and so on. Write a program called Exchange Cipher that prompts user for a plaintext string consisting of mix-
case letters only. Your program shall compute the cipher text; and print the cipher text in uppercase. For
examples, Enter a plaintext string: abcdXYZ The cipher text string is: ZYXWCBA (March Monthly)
32) Problem Statement1:
Write a program which creates a String “Welcome to Java World” and performs the
following Returns the character at 5th position and display it.Compares the above String with “Welcome”
lexicographically ignoring case differences and display the result. Concatenates “- Let us learn” to the above
string and display it.
Returns the position of the first occurrence of character „a‟ and display it. Replaces all the occurrences of „a‟
character with the new „e‟ and display it. Returns string between 4th position and 10th position and display it.
33) Write a program to sort numbers in a String. Display the result as a String.
E.g. if number in String is “43521” result is: “12345”. (April Monthly)
34) Write a program to find largest & smallest word in a string.
35) Write a program to delete all extra spaces in string.
36) Find length of string without using length and tocharArray methods;

Aptitude
Average

1. In the first 10 overs of a cricket game, the run rate was only 3.2. What should be the run rate in the remaining 40
overs to reach the target of 282 runs?
A.6.25 B.6.5 C.6.75 D.7
2. A family consists of two grandparents, two parents and three grandchildren. The average age of the grandparents is
67 years, that of the parents is 35 years and that of the grandchildren is 6 years. What is the average age of the family?
A. 28 4/7 years B. 31 5/7 years C. 32 1/7 years D.None of these
38 | P a g e
3. A grocer has a sale of Rs. 6435, Rs. 6927, Rs. 6855, Rs. 7230 and Rs. 6562 for 5 consecutive months. How much
sale must he have in the sixth month so that he gets an average sale of Rs. 6500?
A.Rs. 4991 B.Rs. 5991 C.Rs. 6001 D.Rs. 6991
4. The average of 20 numbers is zero. Of them, at the most, how many may be greater than zero?
A.0 B.1 C.10 D.19
5. The average weight of 8 person's increases by 2.5 kg when a new person comes in place of one of them weighing
65 kg. What might be the weight of the new person?
A.76 kg B.76.5 kg C.85 kg D.Data inadequate E.None of these
Interview QUEstions:
1) What are Strings in Java? Is string a data type?
2) What are different ways to create string objects?
3) What is String pool?
4) What do you mean by mutable and immutable strings?
5) Why String Buffer is called mutable?
6) Can you create mutable string objects?
7) What is the difference between String Buffer and String Builder class?
8) Why String Buffer and String Builder classes are introduced in java when there already exist string class to
represent the set of characters?
9) What are the various ways of assigning a string literal to a Stringvariable?
10) Which method is used to append a string literal to a String variable?
11) What are the most widely used methods of String class?
12) When will you use String class and when will you use String Buffer?
13) How will you add string to a String Buffer? Give an example.
14) Which class is preferred: String Buffer or String Builder? Why?
15) Is it possible to invoke chained methods in Java? If so, how will you invoke?
16) Can you point out the main difference between C/C++ strings and Java strings?
17) Can the contents of strings in Java be changed?

39 | P a g e
Topic : Strings 2
1) String Buffer class
2) Methods of String Buffer
3) String Builder
4) Methods of String Builder
5) String vs StringBuffer vs StringBuilder
6) String Reader class
7) StringJoiner Class

Assignments:
Check all the methods of String buffer and builder and try string assignments from string buffer and builder

40 | P a g e
Topic: Recursion

ASSIGNMENTS:
1. Print 10 times “Hi” by recursion.
2. Print 1 to 10 by recursion
3. Print 1D array using recursion
4. Fibonacci series by recursion
5. Try Patterns, Array and String using recursion (Without loop)
6. Print below pattern

Aptitude
Area

1. The ratio between the length and the breadth of a rectangular park is 3 : 2. If a man cycling along the
boundary of the park at the speed of 12 km/hr completes one round in 8 minutes, then the area of the park (in sq.
m) is:
A.15360 B.153600 C.30720 D.307200
2. An error 2% in excess is made while measuring the side of a square. The percentage of error in the calculated
area of the square is:
A.2% B.2.02% C.4% D.4.04%
3. The ratio between the perimeter and the breadth of a rectangle is 5 : 1. If the area of the rectangle is 216 sq.
cm, what is the length of the rectangle?
A.16 cm B.18 cm C.24 cm D.Data inadequate E.None of these
4. The percentage increase in the area of a rectangle, if each of its sides is increased by 20% is:
A.40% B.42% C.44% D.46%
5. A rectangular park 60 m long and 40 m wide has two concrete crossroads running in the middle of the park
and rest of the park has been used as a lawn. If the area of the lawn is 2109 sq. m, then what is the width of the
road?
A.2.91 m B.3 m C.5.82 m D.None of these

41 | P a g e
Topic: Exception Handling

SUb-Topics:
1) IntroDUCtion
2) Types of Exceptions
3) Using try-catch
4) MULtiple catch claUSes
5) Exception Hierarchy
6) RUntime stack Mechanism
7) DefaULt Exception handler
8) Types of exceptions
9) Checked exceptions
10) Unchecked exceptions
11) Creating own exceptions
12) Throws vs Throw
13) Use of throw, throws &finally

C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Show Example of runtime stack mechanism using Arithmetic Exception.
2) Show Example of run time stack mechanism using Arithmetic Exception and handle it using try catch.
3) Write a program to display an example to check if an unchecked Exception is propagated in calling stack
4) Write a program to display and explain the use of finally.
5) Display an example of checked exception and simultaneously use multiple catch block.
6) Write a program to display the concept of throw and throws using checked exceptions.
7) Write a program to display the concept of throw and throws using unchecked exception.
8) Write a program to display the concept of throw by creating a user defined exception and use trycatch to handle
the exception.
9) Show an implementation of Try Catch with resources
H/W Assignment
Tip:Trainers will not assist for these questions.
1) Write a program to display an example of how to generate any Exception
2) Write a program to display example where only try and finally block is used.
3) Write a program to display any one Exception and catch that Exception using try catch.
4) Write a program to check and display if we can write an empty catch block?
5) Write a program to generate and handle ArrayIndexOutOfBound Exception using try catch.
6) Write a program to display a message if main method throws an exception.
7) Write a program to display and check if checked Exception is propagated in callingstack.

42 | P a g e
8) Create a class, Demo with a method, division with two int parameters
a. Dividend b. Divisor
This method should divide the dividend by divisor and return the result.
This method should also throw an Arithmetic Exception to the calling method. Step 2: Create a class, Throws
Demo with a main method
The main method should invoke the division method in Demo class
The main method should also catch the Arithmetic Exception thrown by the division method and print the
Exception “Arithmetic Exception is Thrown”
The try/catch block should also have a finally block which prints a message “The result is”<Result>
Step 1:Inthe Demo class division method perform the following logic.
a. If Divisor is zero throw a Arithmetic Exception with message “Divisor cannot be zero”
b. This method should throw this Arithmetic Exception.
c. Step 2: The exception thrown needs to be handled in Throws Demo.
d. The main method should catch the Arithmetic Exception thrown by the division method and print the Exception
and print the message in the exception Object.
e. The try/catch block should also have a finally block which prints a message “The result is”

9) A shopping portal provides users to register their profile. During registration the system needs to
validate the user age above 18 and should be placed in India. If not the system should throw an appropriate error.
a. Create a user defined exception classes named “InvalidCoUNtryException” &
“InvalidAgeException”
b. Overload the respective constructors.
c. Create a main class “User Registration” , add the following method,
i. registerProfile -The parameter are String userName , int age, String country.
ii. Add the following logic
d. if country is not equal to “India” throw a InvalidCountryException with error If age <
18 throw a InvalidAgeException with error message“ User is a Minor”.
e. Invoke the method register Profile from the main method with the data specified and see how the
program behaves:
10) Create a menu driven program Try Catch demo
i) Try Multi Catch
ii) Try Finally
iii) Try Catch Finally
iv) Throw
v) Throws

Aptitude
Permutation Combination

1. From a group of 7 men and 6 women, five persons are to be selected to form a committee so that at least 3 men
are there on the committee. In how many ways can it be done?
A.564 B.645 C.735 D.756 E.None of these
2. In how many different ways can the letters of the word 'LEADING' be arranged in such a way that the vowels
always come together?
A.360 B.480 C.720 D.5040 E.None of these
3. In how many different ways can the letters of the word 'CORPORATION' be arranged so that the vowels always
come together?
A.810 B.1440 C.2880 D.50400 E.5760
4. Out of 7 consonants and 4 vowels, how many words of 3 consonants and 2 vowels can be formed?
A.210 B.1050 C.25200 D.21400 E.None of these
5. In how many ways can the letters of the word 'LEADER' be arranged?
A.72 B.144 C.360 D.720 E.None of these

43 | P a g e
Interview QUEstions:
1) What is an Exception?
2) What is the difference between error and exception?
3) What is the use of the finally block? Is finally block in java guaranteed to be called? When finally
block is not called?
4) What do you mean by Checked Exceptions?
5) Explain Runtime Exceptions?

44 | P a g e
6) Which are the two subclasses under Exception class?
7) When throws keyword is used?
8) What things should be kept in mind while creating your own exceptions inJava?
9) What are the exception handling keywords in java?
10) What is an Exception Hierarchy?
11) Which is the parent class of Exception?
12) In which package throwable interface is present?
13) How does Default Exception Handler works.
14) What are different types of exceptions?
15) What are unchecked exceptions?
16) What is the difference between checked and unchecked exceptions?
17) Explain fully checked exceptions?
18) What are partially unchecked exceptions?
19) What is the main use of keyword throw?
20) What is the use of the finally block?
21) How will you define Exception Handling?
22) What are the different types of Exceptions?
23) How will you handle Exception in Java?
24) Write a compilable code using "try"," catch", and" finally"?
25) What is the use of "finally" clause? Give an example.
26) What are the exception types that can be thrown using the "throw" keyword?
27) How will you write a compilable code block using "throw" keyword?
28) Give a one line definition of an exception. What do you mean by checked and unchecked exceptions?
29) Which class is at the top of the exception hierarchy?

45 | P a g e
Topic: Multithreading

SUb-Topics:
1) IntroDUCtion
2) Thread lifecycle
3) Creation of threads Using class
4) Creation of thread Using interface
5) Creating mULtiple threads
6) Thread scheDULer
7) Synchronization
8) Thread priorities
9) Garbage Collection
10) Daemon Thread
C/W Assignment:
Tip: Trainor‟s will assist for these questions.
1) Write a program to create 2 threads by extending the thread class and then run them concurrently
2) Write a program to create three threads using the Runnable interface and then running them
concurrently
3) Write a program to explain the concept of priorities of a thread. Also show how to set and get priorities
of a thread.
4) Write a program to explain the concept of sleep method by an appropriate example.
5) Write a program to explain and display the concept of daemonthread.
6) Write a program to give the implementation of a thread and pausing of a thread till completion of main
thread using yield ().
7) Write a program to display that main thread calls join() and wait for the child thread to get executed
first and then gets completed by writing two threads main and child thread
8) Write a program to illustrate an example of deadlock.
9) Write a program to show the concept of synchronization by this simple example: Thread1 consumes
biscuits from a box, Thread2 produces fixed number of biscuits at a time say 20. Write a program in which
Thread1 checks for sufficient biscuits in box, it waits for Thread2 to produce if sufficient biscuits are not
available in the box and then consumes given number of biscuits. Thread2 will notify Thread1 after it finishes
producing biscuits.
10) Create a class Item which has sell and buy method when one thread is updating the item the other
thread should not execute on same item.(April Monthly).

46 | P a g e
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Write a program to extend class Thread and create thread also implement runnable interface and create thread
execute threads simultaneously.
2) Write a program in which first thread displays days of a week. Second thread display table of 5.Third thread
displays Fibonacci series by creating 3 threads.
3) Write a program to create thread1 which displays numbers 1 to 10. thread2 displays alphabets A to Z.
Display that alphabets are printed first and then numbers are printed.
Hint: Use join().
4) Write a program to display a synchronized method and 2 threads in which the threads are trying to
update same thread. See how the synchronization works.
5) Write a program to check and display if threads Thread1 and Thread2 are accessing static synchronized
method concurrently.
6) Create Circle class having set Radius(),area(). One thread is calling set Radius(),another thread is
calling area(). Using wait () and notify () implements this program.
Interview QUEstions:
1) What is multithreading?
2) Explain the life cycle of a thread.
3) What is the difference between multi-processing and multithreading?
4) What are the different ways to create a thread?
5) What are the advantages of multithreading?
6) What is thread scheduler?
7) What is synchronization?
8) What do you understand by Garbage collection?
9) How will you define Garbage Collection?
10) When does the garbage collection get executed?
11) Is there any chance that the Java application can throw "out of memory" error? Why?
12) Explain with a code sample when an object is ready for garbage collection.
13) What are the situations in which JVM triggers garbage collection?
14) What are the lines of code you need to write to programmatically trigger garbage collection?
15) What are the concepts that come to your mind about finalize()method?
16) How will you define a Thread?

47 | P a g e
17) How will you create Threads in Java? What are the methods of Thread class that are mainly used to
manage threads?
18) How does a thread get executed in Java?
19) What are the thread states?
20) Write a compilable Java code that creates a child thread using "Thread" class.
21) What are the methods of Objects that are used while managing threads?
22) Is it possible to create more than one thread in a Java application? If so, how will the threads
communicate with each other?
23) How will you define Synchronization?
24) How will you make a thread to pause for ten minutes?
25) How will you use the "synchronized" keyword? Give code examples.
26) What happens when a synchronized method is invoked?
27) How will you make the thread to wait and start its execution a gain so that certain process gets
executed?
• Write a Java code and implement "wait" and "notify" methods.
28) What are the methods that belong to "Runnable" interface?
29) What is the use of join () and yield ()methods?

48 | P a g e
49 | P a g e
Topic: LinkedList and Tree

1) LinkedList
a. Implement queue and stack using linked list
2) Tree

50 | P a g e
Topic: Collections -list

SUb-Topics:
1) IntrodUction 2)Lists
3)Array List- IntrodUction 4)ConstRUCtors & methods of Array List
5)Linked List-IntrodUction 6)ConstRUctors & methods of Linked List
7)Difference between Array List & Linked List 8)Vector–IntroDUction
9) ConstRUCtors & Methods of Vectors
10) Stack-IntroDUction
11) ConstRUCtors & Methods of Vectors
12) CURSors- IntroDUCtion
13) ENUMeration
14) ConstRUCtors & Methods of ENUmeration
15) Limitations of ENUMeration
16) Iterator- IntroDUCtion
17) ConstRUCtors & Methods of Iterator
18) Limitations of Iterator
19) List Iterator
20) ConstRUCtors & Methods of List Iterator
21) Difference between ENUMeration, Iterator and ListIterator
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Write a program to create a new array list, add some colors (string) and print out the collection
2) Write a program to iterate through all elements in a array list.
3) Write a program to insert an element into the array list at the first position.
4) Write a program to retrieve an element (at a specified index) from a given array list.

5) Write a program to update specific array element by given element.


6) Write a program to remove the third element from a array list.
7) Write a program to shuffle elements in a array list.
8) Write a program to sort a given array list.
9) Write a program to reverse elements in a array list.
10) Write a program to copy one array list into another.

51 | P a g e
H/W Assignment:
Tip:Trainers will not assist for these questions.
1) Write a program to extract a portion of a array list.
2) Write a program to compare two array lists
3) Write a program to join two array lists.
4) Write a program to clone an array list to another array list.
5) Write a program to append the specified element to the end of a linked list.
6) Write a program to iterate through all elements in a linked list.
7) Write a program to iterate through all elements in a linked list starting at the specified position.
8) Write a program to iterate a linked list in reverse order.
9) Write a program to insert elements into the linked list at the first and lastposition.
10) Write a program to insert the specified element at the front of a linked list.
11) Write a program to insert the specified element at the end of a linkedlist.
12) Write a program to insert some elements at the specified position into a linked list
13) Write a program to get the first and last occurrence of the specified elements in a linked list
14) Write a program to display the elements and their positions in a linked list.
15) Write a program to remove a specified element from a linked list
16) Write a program to remove first and last element from a linked list.
17) Write a program to remove all the elements from a linked list.
18) Write a program to shuffle the elements in a linked list.
19) Write a program to join two linked lists.
20) Write a program to clone an linked list to another linked list.
21) Write a program to remove and return the first element of a linked list.
22) Write a program to retrieve but does not remove, the first element of a linkedlist.
23) Write a program to retrieve but does not remove, the last element of a linked list.
24) Write a program to check if a particular element exists in a linked list.
25) Write a program to convert a linked list to array list.
26) Write a program to compare two linked lists.
27) Write a program to replace an element in a linked list.

Interview QUEstions:

1) Explain Collections hierarchy?


2) Explain Difference between Vector and Array List?

52 | P a g e
3) What is the difference between array and arraylist?

4) How to sort array list?


5) How to create and initialize array list?

6) What is a linkedlist?
7) How to reverse a linkedlist
8) What is singly linkedlist?
9) What is the difference between Array and linkedlist?
10) Which collection would you choose if you want no duplicates and if objectsare not stored in an order?
11) How will you use the Comparator interface in your class file? 12)What are the activities that can be
performed in collectionAPI?
13) In collection, which method is used to remove the head of the queue?
14) Which collection class method is not synchronized but allows
15) growing or shrinking its size and provides indexed access to its elements? 16)How will you extract
elements from a collection with out knowing
17) how the collection is implemented?
18) What are the different Collection Interfaces in Java collectionframework? Distinguish them.
19) What is Hashtable? What is its significance in Java?

53 | P a g e
Topic: Collections Set

SUb-Topics:
1) introDUCtion
2) Hash Set-declaration, constrUCtors ,methods
3) Sorted Set
4) Tree Set
5) Linked Hash Set
C/W Assignment:
Tip:Trainers will assist for these questions.

1) Write a program to append the specified element to the end of a hash set
2) Write a program to iterate through all elements in a hashlist.
3) Write a program to get the number of elements in a hash set.
4) Write a program to empty an hash set.
5) Write a program to test a hash set is empty or not.
6) Write a program to clone a hash set to another hash set.
7) Write a program to convert a hash set to an array.
8) Write a program to convert a hash set to a tree set. H/W Assignment :
Tip:Trainers will not assist for these questions.

1) Write a program to compare two hash set.


2) Write a program to compare two sets and retain elements which are same on bothsets.
3) Write a program to remove all of the elements from a hash set.
4) Write a program to create a new tree set, add some colors (string) and print out the tree set.
5) Write a program to iterate through all elements in a tree set.
6) Write a program to add all the elements of a specified tree set to another treeset.
7) Write a program to create a reverse order view of the elements contained in a given tree set.
8) Write a program to get the first and last elements in a tree set.
9) Write a program to clone a tree set list to another tree set.
10) Write a program to get the number of elements in a tree set.
11) Write a program to find the numbers less than 7 in a treeset.
12) Write a program to get the element in a tree set which is greater than or equal to the given element.

54 | P a g e
13) Write a program to get the element in a tree set which is less than or equal to thegiven element.
14) Write a program to retrieve and remove the first element of a tree set.
15) Write a program to retrieve and remove the last element of a tree set.
16) Write a program to remove a given element from a tree set
17) Write a program to convert a hash set to a List/ArrayList.

55 | P a g e
Topic: Queue

SUb-Topics:
1) introDUCtion
2) QUEUE
3) Priority QUEUE-declarations, constrUCtors, methods
C/W Assignment:
Tip:Trainers will assist for these questions.
1) Write a program to create a new priority queue and print out the elements of the priority queue.
2) Write a program to iterate through all elements in priority queue.
3) Write a program to add all the elements of a priority queue to another priorityqueue
4) Write a program to insert a given element into a priority queue.
H/W Assignment:
Tip:Trainers will not assist for these questions.

1) Write a program to remove all the elements from a priorityqueue.


2) Write a program to count the number of elements in a priority queue.
3) Write a program to compare two priority queues.
4) Write a program to retrieve the first element of the priority queue.
5) Write a program to convert a priority queue to an array containing all of the elements of the queue.
6) Write a program to change priorityQueue to maximum priorityqueue.
Interview Questions:

1) Explain Difference between HashMap and HashTable?


2) Explain Difference between Iterator andList Iterator?
3) Why Map interface does not extend Collection interface?
4) How HashSet store elements?
5) Difference between iterator and ListIterator?
6) Can a null element added to a TreeSet orHashSet?
7) What are Identity HashMap and Weak HashMap?
9) How to make a collection read only?
10) How to make a collection thread safe?
11) What is difference between fail-fast andfail-safe?
12) What is Comparable and Comparatorinterface?

56 | P a g e
Topic: Collections Sorting

SUb-Topics:
1) IntroDUCtion
2) Sorting in collection
3) String objects
4) User-defined class objects
5) Comparable interface
6) Comparator interface
7) Comparable vs Comparator
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.

1) Write a program to create a class Employee with a p p r o p r i a t e d a t a m e m b e r s . D i s


p l a y a n d e x p l a i n t h e Comparator implementations for each Employee attribute.
2) Create an arraylist and add members and then sort arraylist of employees in ascending order of their salaries and
display names in descending order if their salaries are same.

H/W Assignment:
Tip:Trainers will not assist for these questions.

1) Explain and display the use comparator by a suitable example.


2) Write a program to sort the elements of arrayList which contains String objects. Print the same
Array List with and without using sort().
3) Write a program to create class Student having name, rollNo ,marks as variables .Create and add 8
Students .Display the data of students performing sorting depending on name and salary.(March Monthly).

57 | P a g e
Topic: Collections Map

SUb-Topics:
1) introDUCtion
2) Methods-PUT, PUT All, get etc.
3) Hash Map
4) Sorted Map
5) Tree Map
C/W Assignment:
TIP: TRAINERS WILL ASSIST FOR THESE QUESTIONS.
1) Write a program to associate the specified value with the specified key in a HashMap.
2) Write a program to count the number of key-value (size) mappings in a map
3) Write a program to copy all of the mappings from the specified map to another map.
4) Write a program to remove all of the mappings from a map
H/W Assignment:
TIP: TRAINERS WILL NOT ASSIST FOR THESE QUESTIONS.
1) Write a program to check whether a map contains key-value mappings (empty) or not.
2) Write a program to test if a map contains a mapping for the specified key.
3) Write a program to test if a map contains a mapping for the specified value.
4) Write a program to create a set view of the mappings contained in a map.
5) Write a program to get the value of a specified key in amap.
6) Write a program to get a set view of the keys contained in this map.
7) Write a program to get a collection view of the values contained in this map.
8) Write a program to associate the specified value with the specified key in a Tree Map
9) Write a program to search a key in a Tree Map.
10) Write a program to copy a Tree Map content to another Tree Map.
11) Write a program to get all keys from the given a Tree Map.
12) Write a program to search a value in a Tree Map.
13) Write a program to delete all elements from a given Tree Map.
14) Write a program to sort keys in Tree Map by using comparator.
15) Write a program to get a key-value mapping associated with the greatest key and the least key in a
map.
16) Write a program to get a key-value mapping associated with the greatest key less than or equal to the
given key.
17) Write a program to get the greatest key less than or equal to the given key.
18) Write a program to get a reverse order view of the keys contained in a given map.
19) Write a program to get the first (lowest) key and the last (highest) key currently in a map.

Interview QUEstions:
1) Why we use map interface?
2) What are the main classes implementing Map interface?
3) How Hash map works?
4) When to use Hash Map or Tree Map?

58 | P a g e
Additional Points:
1. Singleton class
a. Implement a singleton class
2. 2D arrayList
a. Implement 2D arrayList
3. Interface
a. Use static and default method in interface
b. Use Marker Interface
c. Use functional interface
d. Make a use of Lamda function and implement functional interface
4. Check all methods of Arrays class
5. Read and Write in a text file of your laptop
6. dsds

59 | P a g e

You might also like