Java 23-24 Notebook
Java 23-24 Notebook
STUDENT NOTEBOOK
Established by
SRI VISHNU EDUCATIONAL SOCIETY
153, Sita Nilayam, Dwarakapuri Colony, Punjagutta,
HYDERABAD – 500 082. Ph. No. 040 – 23352916
VISION
To empower the students through Academic excellence and Ethics so as to bring about social
transformation and prosperity.
MISSION
1. To expand the frontiers of knowledge through quality education.
2. To provide value added Research and development.
3. To embody a spirit of excellence in Teaching, Creativity, Entrepreneurship and Outreach.
4. To provide a platform for synergy of Academy, Industry and Community.
5. To inculcate high standards of Ethical and Professional behavior.
MISSION
1. To provide strong foundation both in theory and applications of Computer Science &
Engineering, so as to solve real-world problems.
2. To empower students with state-of-art knowledge and up to date technological skills, making
them globally competent.
3. To promote research, innovation and entrepreneurship with focus on industry and social outreach.
VISHNU INSTITUTE OF TECHNOLOGY
Page 2
Department of Computer Science and Engineering Resource 2023-24
4. To foster civic minded leadership with ethics and values among students.
PEO2: Graduates will succeed in earning coveted entry level positions in leading Computer Software
and Hardware Firms in India and abroad.
PEO3: Graduates will succeed in the pursuit of advanced degrees and research in engineering or other
fields and will have skills for continued, independent, lifelong learning and professional development
throughout life.
PEO4: Graduates will have good communication skills, entrepreneurial skills, leadership qualities, ethical
values and will be able to work in teams with due attention to their social responsibilities.
COURSE STRUCTURE
II YEAR I SEMESTER
S.No Category Subjects L T P C I E
1 BS / PC Discrete Mathematical Structures 3 0 0 3 30 70
2 PC Data Structures 3 0 0 3 30 70
3 PC Database Management Systems 3 0 0 3 30 70
4 ESC Object Oriented Programming through Java 3 0 0 3 30 70
5 PC Computer Organization 3 0 0 3 30 70
6 PC Lab Data Structures Lab 0 0 3 1.5 15 35
7 PC Lab Database Management Systems Lab 0 0 3 1.5 15 35
8 PC Lab Object Oriented Programming through Java Lab 0 0 3 1.5 15 35
Skill Oriented Course – I
1) Animations – 2D Animation
9 SO 0 0 4 2 -- 50
2) Web Application Development Using Full
Stack – Module – I
10 MC Environmental Science 2 0 0 0
Total Credits 21.5 195 505
Total Marks 700
(R 20 Regulations)
Computer Science & Engineering (CSE)
Unit I
Introduction to OOP: Introduction, Need of OOP, Principles of Object Oriented Languages,
Procedural languages vs OOP, Applications of OOP, History of Java, JVM, Java Features,
Programming Style, Command Line Arguments, Escape Sequence Comments
Data Types, Variables, Operators and Flow of Control: Variables, Primitive Data types,
Constants, Identifiers- Naming Conventions, Keywords, Literals, Operators- Binary, Unary,
Ternary, Expressions, Precedence rules and Associativity, Primitive Type Conversion and casting,
Flow of Control- Branching, Conditional Loops.
Unit II :
Classes and Objects: Class declaration and Modifiers, Class Members, Declaration of Class
Object, Object Creation, Access control for Class Members, Defining methods, Overloaded
methods, Recursive methods, Constructor, Constructor overloading, static keyword, this keyword.
Inheritance: Types of Inheritance, Deriving classes using Extends keyword, Method Overloading,
super keyword, final keyword, Polymorphism- Abstract classes and methods - Overloading -
Overriding - final methods and classes
Unit III
Packages and Java Library: Defining package, Importing packages and classes into programs,
Path and class path, Access control, Java.lang package and its classes, wrapper classes, auto –
boxing and auto-unboxing, Java util classes and interfaces.
Unit IV
Exception Handling: Introduction, Exception handling techniques- try…catch, throw, throws,
finally block, User defined Exception, checked exception, unchecked exception, custom exception,
nested try and catch blocks
Input/Output and String Handling: Files and streams- Byte stream, I/O stream, Character
StreamFile Reader and Writer, charArrayReader and Writer, Class String, Methods for Extracting
characters from strings, String Methods, String Buffer, Class String Buffer.
Unit V
Mutli- Threading: Introduction, Need for Multiple threads, Mulithreaded Programming, Thread
Class, Main thread, Creation of new thread, thread states, thread priority.
TEXT BOOKS:
1. JAVA one step ahead, Anitha Seth, B.L.Juneja, Oxford.
2. The complete Reference Java, 8th edition, Herbert Schildt, TMH
3. Cay S. Horstmann, Gary cornell, ―Core Java Volume –I Fundamentals, 9th Edition,
Prentice Hall,2013.
REFERENCE BOOKS:
1. Introduction to java programming, 7th edition by Y Daniel Liang, Pearson
2. Murach's Java Programming, Joel Murach
E-Resources:
1) https://nptel.ac.in/courses/106/105/106105191/
2) https://www.w3schools.com/java/java_data_types.asp
LESSON PLAN
PREREQUISITES:
To identify Java language components and how they work together in applications
●
To learn the fundamentals of object-oriented programming in Java, including defining
●
classes, invoking methods, using class libraries.
To learn how to extend Java classes with inheritance and dynamic binding and how to use
●
exception handling in Java applications
To understand how to design applications with threads in Java
●
COURSE OUTCOMES:
After completion of the course, the student will be able to
Able to realize the concept of Object Oriented Programming & Java Programming
●
Constructs
Able to describe the basic concepts of Java such as, classes, objects, packages, Enumeration
●
and various keywords
Develop applications using various types of Inheritance and Interfaces.
●
Able to handle exceptions and perform various input/output operations on strings and files.
●
Write programs using multithreading and interface with databases from Java program.
●
LESSON PLAN
Text / Ref /
Other
No. of
S.No Name of the Topic Books with
Classes
Page
Numbers
Introduction, Need of OOP, Principles
1 of Object Oriented Languages 1 T1-01
Procedural languages vs OOP, T1-03
2 1
Applications of OOP
3 History of Java, JVM, Java Features 1 T1-08
Programming Style, Command Line T2-23
4 1
Arguments, Escape Sequences
5 Primitive Data types, Constants 1 T2-35
Variables, Identifiers- Naming T2-44
6 1
Conventions, Keywords, Literals
7 Operators- Binary, Unary, Ternary 1 T2-61
Expressions, Precedence rules and T2-78
8 1
Associativity
9 Primitive Type Conversion and casting 1 T2-48
Tutorial 1
Total No. of Classes 15
Interface: Declaration of Interface,
21 2 T2-196
Implementation of Interface
T2-197-
22 Multiple Interfaces, Nested Interfaces 1
199,200
Static methods in interface, functional T2-201-
23 2
interfaces. 203, 204
Packages and Java Library: Defining T2-187-188
24 1
package
Importing packages and classes into T2-194
25 2
programs
26 Path and class path, Access control 1 T2-188-191
27 Java.lang package and its classes 3 T2-397
wrapper classes, auto –boxing and auto- T2-268-274
28 1
unboxing
29 Java util classes and interfaces 3 T2-453
Tutorial 1
Total No. of Classes 17
VISHNU INSTITUTE OF TECHNOLOGY
Page 9
Department of Computer Science and Engineering Resource 2023-24
TEXT BOOKS:
T1. JAVA one step ahead, Anitha Seth, B.L.Juneja, Oxford.
T2. The complete Reference Java, 8th edition, Herbert Schildt, TMH
T3. Cay S. Horstmann, Gary cornell, ―Core Java Volume –I Fundamentals, 9th Edition,
Prentice Hall,2013.
REFERENCE BOOKS:
R1. Introduction to java programming, 7th edition by Y Daniel Liang, Pearson
R2. Murach's Java Programming, Joel Murach
E-Resources:
E1. https://nptel.ac.in/courses/106/105/106105191/
E2. https://www.w3schools.com/java/java_data_types.asp
student marks. So write a program to read the position of the marks doubly entered and delete
it, insert the last student marks in the vector.
6. In a company the monthly sales of a year are stored in an vector in lacks. The manager
asked one of his Pa to analyze the sales by arranging the monthly sales in an order as least
monthly sales is first and highest monthly sales at the last. Now you need to help the PA, so
write the program for it and display the sales after rearranging.
7. In a class of 60 students, one day there was a test was conducted and their marks are stored
in an vector Marks. The teacher wants to find the marks most of the students of your class are
getting. So write a program to find it.
8. Mr. Chakradhar wants to play a game. He had taken a vector of elements and was trying to
generate a new number which is going to be obtained by adding each and every digit of the
elements taken in the vector. Help him to generate the number.
9. Write a program to store the elements in the vector in the following
manner: 1 4 27 256 3125…..
10. Write a program to find the kth smallest element in a vector.
11. Write a program to perform the following operation on vector
elements:
Input: 1 2 3 4 5 6 7 8
Output: 6 7 8 1 2 3 4 5
12. Consider a vector of elements. Now you need to find the elements in the vector in such a
way that the current element is immediately followed by next element and print such elements.
Ex: 1 5 4 7 3 2 Ouput: 5 4 3 2
13. Mr. Praveen is given a box full of chocolates. The box arrangement is in such a way that
there is a rack for each chocolate. Now he was asked to arrange the chocolates in such a way
that he has to replace the chocolates in even positions with another set of chocolates of same
type. Help Praveen to arrange the chocolates.
14. A company has stored the monthly profits earned by it in a vector. The chairman of that
company wants to find out what was the highest profit in between a given set of months and
also the month in which the profit earned. He also wants to find out the lowest profit earned
between the given months along with the month in which the profit earned. Write a program
to make the company analyze their profits.
15. Mr. Sripad has been given a vector of elements by his friend Kalki. Now kalki asked
sripad to find the elements in the vector which are perfect numbers. If no such elements are
present he asked him to say “NO”. Help sripad to do the task.
14. A test was conducted to 60 students in a class. The test had 20 MCQ questions with each
question having 4 choices. You were given the correct answers for all the 20 questions. Write a
program to find the score secured by each student and prints it.
Assume the following facts
Correct answers are in 1D vector ANSWERS of size 20
Student responses were stored in 2D vector RES of size 60 X 20.
15. Write a program to read integers continuously in the range of (0 to 9) until 99 is entered and
do the following operations,
Count how many times each digit is present and display it.
PROGRAMS ON RECURSION
1. We have 'n' number of bunnies and each bunny has two big floppy ears. We want to
compute the total number of ears for all the bunnies recursively (without loops or
multiplication).
For example,
bunnyEars(1) → 2
Sample Input:
1
Sample Output:
2
Function specification:
int computeSum(int n)
Sample Input 1:
Enter the value of n
432
Sample Output 1:
The sum of digits in 432 is 9
3. We have triangles made of wodden blocks. The topmost row has 1 block, the next row
down has 2 blocks, the next row has 3 blocks, and so on. Compute recursively (no loops or
multiplication) the total number of blocks in such an arrangement of triangles with the given
number of rows.
For example,
triangle(2) → 3
Sample Input :
2
Sample Output :
3
5. Given a string, compute recursively (no loops) the number of lowercase 'x' chars in the
string.
For example,
countX("axxhixxbc") → 4
Sample Input :
axxhixxbc
Sample Output :
4
4
Enter the elements in the array
23
45
67
89
The elements in the array are
23
45
67
89
7. Write a program to print the elements in an array in reverse order using recursion.
4
Enter the elements in the array
23
45
67
89
The elements in the array in reverse order are
89
67
45
23
8. Write a program to find the sum of the elements in an array using recursion.
9. Write a program to find the sum of the even numbers present in an array using recursion
QUESTION BANK
UNIT-I
1. List and explain object oriented programming principles.
2. Write the differences between procedure oriented and object oriented programming
techniques.
3. Write a program to find the largest of three numbers.
4. Explain JAVA features in detail.
5. Draw the JVM architecture and explain the architecture in detail.
6. What is a data type? Explain data types available in JAVA language.
7. Explain the following operators with an example each.
Logical operators
Increment and decrement operators
Bit-wise operators
8. What is type conversion? Explain types of type conversions with examples.
9. Write a program that reads two operands and perform arithmetic operations using switch
statement by taking user choice.
10. Explain else-if ladder with an example.
11. Write a program to check whether the given number is palindrome or not.
12. Explain for loop in detail with an example.
13. Write a program to display the prime numbers between 1to n where n is supplied by the user.
UNIT – II
1. Define a class. Explain how to declare a class and how to create an object with an example.
2. Explain access control for class members with an example.
3. What is method overloading? Write a program to illustrate method overloading.
4. What is recursion? Write a program to find the factorial of a given number using recursion.
5. Write a program to create a class with methods and invoke the methods inside main method.
6. Explain this keyword with an example.
7. What is a constructor? Explain types of constructors with examples.
8. What is constructor overloading? Write a program to illustrate constructor overloading.
9. Discuss about static keyword with an example program.
10. What is inheritance? Explain types of inheritances in detail.
11. Explain how to derive a class from another class with an example
12. Write a program to implement multi level inheritance.
13. Explain the usage of super keyword with an example.
14. What is method overriding? Write a program to illustrate method overriding.
15. What is an abstract class? Explain how to create abstract class with an example.
16. Write the differences between method overloading and method overriding.
UNIT –III
1. Define interface. Explain how to declare an interface and how to implement an interface with
an example.
2. How multiple inheritance can be achieved by using interfaces? Explain with an example.
3. Explain nested interfaces with an example.
UNIT-IV
1. What is an exception? Explain how to handle an exception in JAVA with an example.
2. a) Explain the usage of throw keyword with an example.
b) Write a program that illustrates the use of throws keyword.
3. a) Write the differences between checked and unchecked exceptions
b) Write a java program that creates user defined exception
4. a) What are JAVA’s built-in exceptions? Write the importance of finally block with an
example.
b) Explain the purpose of streams. List out various classes available for reading and writing.
5. a) Explain about FileInputStream and FileOutputStream in JAVA with an example.
b)Write a program to copy the contents of one file into another file.
UNIT-V
VISHNU INSTITUTE OF TECHNOLOGY
Page 22
Department of Computer Science and Engineering Resource 2023-24
1. Define a thread. What are the different ways to create threads in JAVA? Explain with an
example each.
2. Write a java program that creates three threads. First thread displays “Good morning” in every
one second, the second thread displays “Hello” in every two seconds, and the third thread
displays “Welcome” in every three seconds.
3(b) I What are the uses of ‘super’ and ‘final’ keywords. Explain. L1 CO3 [5M]
II What is the Thread life cycle? Explain. L1 CO3 [5M]
4(a) Write the need of exceptional handling. Illustrate the uses of ‘try, catch, L2 CO4 [10M]
throw, throws and finally’ in exception handling.
(OR)
4(b) I Write a Java program to read from file and print file data on the user screen. L3 CO4 [5M]
II What is an Assertion in JAVA? Write JAVA program to illustrate the L3 CO4 [5M]
importance of assert statement.
5(a) What is collection framework. Write the class heirarchy in collection L3 CO5 [10M]
framework.
(OR)
5(b) How Array Lists are different from arrays in java. Write a java program to L2 CO5 [10M]
create and manage the elements in Array Lists.
6(a) I Write a java program to add, retrieve and delete elements in Array List. L3 CO6 [5M]
II Write a program to create and display the linked lists. L2 CO6 [5M]
(OR)
6(b) I What is mapping? Explain the mapping operations on Lists. L2 CO6 [5M]
II Differentiate the priority queue and normal queue. Write a program to L2 CO6 [5M]
create priority queues.
*****
II With a neat diagram, explain the Java Virtual Machine architecture. L1 CO1 [5M]
2(a) I What are objects and how they are created from Class? Explain the L1 CO2 [5M]
dynamic initialization of objects using constructors.
II Write the importance of command line arguments with an example. L2 CO2 [5M]
(OR)
2(b) I Explain how garbage collection happens in Java. L3 CO2 [5M]
II Explain and write a program to demonstrate the method overloading. L2 CO2 [5M]
3(a) I Define an interface. Explain the definition and implementation of interface L2 CO3 [5M]
in java with suitable example.
II Explain how to set the priority of threads. L2 CO3 [5M]
(OR)
3(b) I What is a package in java. Explain how to create and import packages in L2 CO3 [5M]
java with example.
II Explain the different ways of creating a threads with an examples. L2 CO3 [5M]
4(a) I Write the procedure to read from a file using File Reader class L3 CO4 [5M]
II What is the importance of Exception Handling in Java? Define and L2 CO4 [5M]
distinguish between checked and unchecked exceptions.
(OR)
4(b) I Write the purpose of File Input Stream and File Output Stream with an L2 CO4 [5M]
example.
II What is an exception in java. Write a program to demonstrate the L2 CO4 [5M]
Arithmetic Exception and Array Index Out Of Bounds Exception.
5(a) I Write the importance of Generic methods and Generic classes in java. L2 CO5 [5M]
II Differentiate the String and String Buffer class L1 CO5 [5M]
(OR)
5(b) I What is the importance of String Tokenizer class. Write a program to read L1 CO5 [5M]
a string and display the words as tokens.
II What is a set? Differentiate the Hash Set and Linked Hash Set with an L2 CO5 [5M]
example.
6(a) Differentiate the Array List and Linked List in java. Write a program to L2 CO6 [10M]
add and manage the elements in both the lists.
(OR)
6(b) I what is lambda expression? Explain functional filtering and mapping L3 CO6 [5M]
operations on lists with lambdas.
II What is a map? Write a program to demonstrate mapping operations on L2 CO6 [5M]
lists.
*****
VISHNU INSTITUTE OF TECHNOLOGY
Page 27
Department of Computer Science and Engineering Resource 2023-24
(OR)
(OR)
10 a Write a program to tokenize a string having the following four delimiters L CO [5M]
b What are the differences between Array List and Linked List L CO [5M]
11 a Write a program to insert employee objects into the Tree Set where L CO [5M]
default natural sorting order is ascending order of salaries. If two
employees have same salary then consider alphabetical orders of their
names, and Write a comparator class to define customized sorting which
is alphabetical order of employee names. If two employees have same
name then consider descending order of their age.
b Write a Java program to append the specified element to the end of a L CO [5M]
linked list.
(OR)
12 a Write a Java program to compare two tree sets. L CO [5M]
b Write a program to sort Hash Map by keys. L CO [5M]
*****
1 a Establish the principles of OOP and how OOP principles are useful in L CO [5M]
developing sustainable programs.
b What are primitive data types in Java. Does Java support unsigned L CO [5M]
integer data type?.
(OR)
2 a How does Java handle conversions between different data types? What L CO [5M]
conversions happen automatically? What conversions will not happen
automatically? When Java doesn’t convert automatically, how do you
handle?
b Create a 5 element array which represents marks in five subjects. The L CO [5M]
elements are the following :
i. English Marks
ii. Telugu Marks
iii.Social Marks
iv.Science Marks
v. Hindi Marks
List the situations when such arrays are useful.
3 a Define method overloading. Give proper examples? L CO [5M]
b Write a program to enter the numbers till the user wants and at the end it L CO [5M]
should display the count of positive, negative and zeros entered.
(OR)
4 a What is the output of the following program? Explain. L CO [5M]
class Test1 {
static int x = 10;
public
static void main(String[] args)
{
Test1 t1 = new Test1();
Test1 t2 = new Test1();
t1.x = 20;
System.out.print(t1.x + " ");
System.out.println(t2.x);
}
}
b Can we use “this within static method? Justify your answer. L CO [5M]
5 a Illustrate the uses of abstract class with examples L CO [5M]
b Can we pass an object of a subclass to a method expecting an object of L CO [5M]
the super class? Explain with an example
(OR)
6 a What is significance of Synchronization of Threads? How Java achieves L CO [5M]
VISHNU INSTITUTE OF TECHNOLOGY
Page 31
Department of Computer Science and Engineering Resource 2023-24
it?
b Justify: “Multiple Inheritance is not supported through a class in Java, L CO [5M]
but it can be possible through the interface.” Illustrate with an example.
7 a How to write custom exception in Java? Write a custom exception to L CO [5M]
handle withdrawal of money from a bank account when balance is below
one thousand rupees.
b How can you append text to an existing file? L CO [5M]
(OR)
8 a What is RandomAccessFile? What is the benefit of using L CO [5M]
RandomAccessFile?
b Illustrate the difference between checked and unchecked Exception in L CO [5M]
Java?
9 a I Using Collections framework, search for your name in a list of student L CO [5M]
Names
b Why strings are immutable in Java? L CO [5M]
(OR)
10 a Lists the differences between String, StringBuffer and StringBuilder. L CO [5M]
b What are the main differences between array and collection L CO [5M]
11 a Write a Java program to iterate through all elements in priority queue. L CO [5M]
b Write a program to iterate TreeMap. L CO [5M]
(OR)
12 a Write a Java program to get a key-value mapping associated with the least L CO [5M]
key in a map.
b Write a program to remove element from specified index of ArrayList L CO [5M]
*****
H.T.No:
Course Code No: 20IT3T02
b Write a java program to find the maximum value in given three values. L1 CO1 [7M]
UNIT – II
3 a What is a Constructor? Write a java program to illustrate Constructor L1 CO2 [7M]
Overloading.
b Explain the Dynamic Method Dispatch in Java with example L2 CO2 [7M]
OR
4 a Write the various purposes of “this” keyword in syntax and explain them 1 CO2 [7M]
with appropriate programs.
b What is method over loading ? Explain with example program. L1 CO2 [7M]
UNIT – III
5 a Give an example of how an interface can be used to support multiple L1 CO3 [7M]
inheritances.
b Write a java program to find the factorial value of the given number L2 CO3 [7M]
using a user-defined package concept.
OR
6 a What is an interface? How will you define and access an interface? L3 CO3 [7M]
b Explain the creation and importing of packages with suitable examples L1 CO3 [7M]
UNIT – IV
7 a What are the different ways to handle exceptions? Explain. L1 CO4 [7M]
VISHNU INSTITUTE OF TECHNOLOGY
Page 33
Department of Computer Science and Engineering Resource 2023-24
b Write a java program to read the file contents and copy the content to L2 CO4 [7M]
another file.
OR
8 a Explain the following in detail with an example L3 CO4 [7M]
a) throw b) throws c) finally
b Write about various stream classes in java. L1 CO4 [7M]
UNIT – V
9 a What is a thread? Explain the various thread priorities. L1 CO5 [7M]
b What is JDBC? Explain steps for connectivity between java program L2 CO5 [7M]
and database
OR
10 a Explain the different ways in which a thread can be created. Also, write L3 CO5 [10M]
programs for each type.
b What is the difference between row set and result set in Java? L1 CO5 [4M]
*****
H.T.No:
Course Code No: 20IT3T02
UNIT – IV
7 a What is an exception? Explain how to handle the exceptions in java. L1 CO4 [7M]
b Differentiate the String and String Buffer Class. L2 CO4 [7M]
OR
8 a Write a java program to create and extract the text file in java. L3 CO4 [7M]
b Explain about checked and unchecked exceptions in java. L1 CO4 [7M]
UNIT – V
9 a What is the concept of multi-threading? Explain different states of thread. L1 CO5 [7M]
b Explain the JDBC Architecture. L2 CO5 [7M]
OR
10 a Explain the steps in connectivity of JDBC. L3 CO5 [7M]
b What is synchronization of threads? Explain. L1 CO5 [7M]
*****