Nothing Special   »   [go: up one dir, main page]

Java 23-24 Notebook

Download as pdf or txt
Download as pdf or txt
You are on page 1of 36

Department of Computer Science and Engineering Resource 2023-24

VISHNU INSTITUTE OF TECHNOLOGY


(AUTONOMOUS)
VISHNUPUR, BHIMAVARAM – 534 202

STUDENT NOTEBOOK

OBJECT ORIENTED PROGRAMMING


THROUGH JAVA

II B.Tech. I Semester CSE :: 2022 – 23

Established by
SRI VISHNU EDUCATIONAL SOCIETY
153, Sita Nilayam, Dwarakapuri Colony, Punjagutta,
HYDERABAD – 500 082. Ph. No. 040 – 23352916

VISHNU INSTITUTE OF TECHNOLOGY


Page 1
Department of Computer Science and Engineering Resource 2023-24

VISHNU INSTITUTE OF TECHNOLOGY

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.

DEPARTMENT OF COMPUTER SCIENCE AND


ENGINEERING
VISION
To build a strong teaching-learning base with a flair for innovation and research that responds to the
dynamic needs of the software industry and the society with good ethical practices.

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.

PROGRAM EDUCATIONAL OBJECTIVES (PEOs)


PEO1: Graduates will have knowledge of mathematics, science, engineering fundamentals, and in-depth
studies in Computer Science Engineering, and will be able to apply them for formulating, analyzing and
solving real world problems.

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.

VISHNU INSTITUTE OF TECHNOLOGY


Page 3
Department of Computer Science and Engineering Resource 2023-24

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 4
Department of Computer Science and Engineering Resource 2023-24

Department of Computer Science & Engineering


Syllabus: II B.Tech-I Semester

(R 20 Regulations)
Computer Science & Engineering (CSE)

Course Title: Object Oriented Programming Through Java

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 5
Department of Computer Science and Engineering Resource 2023-24

Interface: Declaration of Interface, Implementation of Interface, Multiple Interfaces, Nested


Interfaces, Static methods in interface, functional interfaces.

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.

Java Database Connectivity: Introduction, JDBC Architecture, Environment Setup, JDBC


Database Connections, Resultset Interface, Creating JDBC Applications

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 6
Department of Computer Science and Engineering Resource 2023-24

LESSON PLAN

CLASS: II Year I Sem. BRANCH: CSE


SUBJECT: Object Oriented Programming Through Java ACADEMIC YEAR: 2022-23

PREREQUISITES:

Basic knowledge of OOP’s is required.



COURSE OBJECTIVES: Students are expected to

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 7
Department of Computer Science and Engineering Resource 2023-24

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 8
Department of Computer Science and Engineering Resource 2023-24

Flow of Control- Branching, T2-81


10 3
Conditional Loops
Tutorial 1
Total No. of Classes 13
11 Class declaration and Modifiers 2 T1-104
Class Members, Declaration of Class T2-113
12 2
Object, Object Creation
Access control for Class Members, T2-115-
13 Defining methods, Overloaded methods, 2 119,
Recursive methods 129,139
14 Constructor, Constructor overloading 1 T2-121
static keyword, this keyword. T2-124-
15 1
125,146
Inheritance: Types of Inheritance, T2-161-164
16 2
Deriving classes using Extends keyword
17 Method Overloading, Super keyword 1 T2-167
18 Final keyword, Polymorphism 1 T2-175
19 Abstract classes and methods 1 T2-181
Overloading-Overriding-final methods T2-184
20 and classes 1

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

Exception Handling: Introduction,


30 1 T2-207
Exception handling techniques
T2-210-
31 try…catch, throw, throws, finally block 1 212, 216-
218
32 User defined Exception 1 T2-221
checked exception, unchecked
33 1 T2-208-209
exception, Custom Exception
nested try and catch blocks
34 1 T2-212-214
Files and streams- Byte stream, I/O
35 2 T2-290
stream
Character Stream, File Reader and T2-290-
36 1
Writer 294, 297
37 charArray Reader and Writer 1 T2-293-294
Class String, Methods for Extracting
38 1 T2-377-378
characters from strings
39 String Methods 3 T2-377-387

40 Class String Buffer 2 T2-389-394


Tutorial 1
Total No. of Classes 16
Introduction, Need for Multiple threads
41 2 T2-227-230

Mulithreaded Programming- Thread


42 Class, Main thread, Creation of new 2 T2-231-236
thread
43 thread states, thread priority 1 T2-238-240
Introduction, JDBC Architecture T1-1102-
44 1
1105
45 Environment Setup 1 T1-1106
46 JDBC Database Connections 1 T1-1108
47 Resultset Interface 1 T1-1113
48 Creating JDBC Applications 1 T1-1116
Tutorial 1
VISHNU INSTITUTE OF TECHNOLOGY
Page 10
Department of Computer Science and Engineering Resource 2023-24

Total No. of Classes 11

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 11
Department of Computer Science and Engineering Resource 2023-24

PROGRAMS FOR PRACTICE


PROGRAMS ON NUMBERS
1. Write a program to find the sum of digits of a number(Example: 143=1+4+3=8)
2. Write a program to find the reverse of a number(Example: 143=341)
3. Write a program to check whether an n digited number is Armstrong or not.(also called
as narcissistic number.Example:1634 is an Armstrong number,54748 is an Armstrong
number)
4. Write a program to check whether a given number is an ugly number or not.(Hint: Ugly
numbers are numbers whose only prime factors are 2, 3 or 5.) Example: 324,1296
5. Write a program to check whether a given number is Deficient or not.( A number n is
said to be Deficient Number if sum of all the divisors of the number is less than twice the value
of the number n.)Example:86
6. Write a program to check whether a number is harshad number or not(If sum of digits
of a number divides the given number then it is called harshad number. Also called as niven
number)Examples 195,200
7. Write a program to check whether a given number is pronic or not(also called as
heteromecic number) Example: 930=30*31
8. Write a program to check if a given number is authomorphic or not(A number is called
Automorphic number if and only if its square ends in the same digits as the number itself.)
Example:25,76

VISHNU INSTITUTE OF TECHNOLOGY


Page 12
Department of Computer Science and Engineering Resource 2023-24

PROGRAMS ON 1-D ARRAYS


1. Raman has been given a vector of elements. A task was given to him that he need to find
even and odd elements in the vector and all the even elements are needed to be stored in a
vector with the name as “even” and all odd elements must be stored in a vector with name as
“odd”. Help Raman to do the splitting.
2. In an organization n employees are working in the sales department. Their salaries are stored
in an vector named as salary. Now you need to find the following
a. Find the maximum, minimum and second maximum salaries paid by the company
to these employees.
b. Find the average of salaries paid by the company.
c. Find the salary which is uniquely paid by the company to their employees.
d. Consider if salary is more than or equal to 20,000 then they considered as officers,
salary is more than or equal to 12,000 then they considered as supervisors and salary is less
than 12000 they considered as daily workers. So find the number of employees working as
officers, supervisors and daily workers worked in the company.
3. Mr. Srinu reads n integer numbers into an vector ranging from 1 to 100, and asked to his
friend Vinay to read a random number and find the number is existing in the given numbers
of the vector. If it exists you need to print its position in the vector. If not exist then print
number not exist in the given numbers.
4. A class is having n students. All these students are standing on a long table. Their heights
are stored in an vector. One of the student said that we want play a game as follows, first
person wants to change their position with last person, second person wants to change their
position with last but one and so on until each student shifted his position at most once. Now
display their heights after changing their positions on the table.
5. In a class n students wrote an examination. The teacher enters their marks in an vector
according with their roll numbers. After insertion of all the marks the teacher found that
a. One of the student marks was not entered, so write the program to insert the student
marks by the given position in an vector.
b. One of the student marks was wrongly entered, so write the program to replace the
correct marks by the given position in an vector.
c. Due to misunderstanding of marks instead of 35, the teacher entered 85 marks in the
vector. So program to replace the marks and display the marks.
d. One of the student marks was double entered, so at the end there is no space for one

VISHNU INSTITUTE OF TECHNOLOGY


Page 13
Department of Computer Science and Engineering Resource 2023-24

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.

VISHNU INSTITUTE OF TECHNOLOGY


Page 14
Department of Computer Science and Engineering Resource 2023-24

PROGRAMS ON 2-D ARRAYS


1. Write a program to create a 2-d vector which consists of elements generated as
row*10+column.
2. Write a program to take a 2-D vector as input and print the output in such a way that all
the edge elements must be filled with zero’s.
3. Write a program to sort the even numbered row elements in ascending order and the odd
numbered row elements in descending order of a 2-D vector.
4. Write a program to find the sum of the diagonal elements(both the leading and anti
diagonals).
5. Write a program to interchange only the diagonal elements.
6. Write a program to check whether a given 3X3 matrix is magic square or not.
7. Write a program to generate a 3X3 magic square.
8. Mr. Jagadeesh asked his students to play a game. He has 2-D vector with elements in it and
asked them to generate a new 2-D vector in such a way that all the elements except the diagonal
elements should be filled with zero’s. Let us play the same game.
9. program to find the given matrix is symmetric or not.
10. program to read a matrix and then find the transpose of a matrix and display it.
11. program to print the lower triangular matrix
12. Given a nXn matrix to you, your task is to rotate the matrix 90 degrees in clockwise
direction If input matrix is then output should be
12 31
34 42
13. Miss. Srujanalaya was asked by her faculty to generate a 2-D vector in the following
manner
123
894
765
It’s a bit complicated for her as she doesn’t know anything about 2-D vectors. Help her to solve
the problem so that she will get ‘A’ grade.

14. A test was conducted to 60 students in a class. The test had 20 MCQ questions with each

VISHNU INSTITUTE OF TECHNOLOGY


Page 15
Department of Computer Science and Engineering Resource 2023-24

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.

To display unique digits

To display non unique digits


To display digits those are not entered.

VISHNU INSTITUTE OF TECHNOLOGY


Page 16
Department of Computer Science and Engineering Resource 2023-24

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

2. Write a program to find the sum of digits in a number using recursion.


Note:
Refer to the problem requirements.

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 :

VISHNU INSTITUTE OF TECHNOLOGY


Page 17
Department of Computer Science and Engineering Resource 2023-24

2
Sample Output :
3

4. Write a program to compute a^n (a power n) using recursion.


Sample Input and Output1:
Enter the value of a
2
Enter the value of n
8
The value of 2 power 8 is 256

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

6. Write a program to print the elements in an array using recursion.

Enter the number of elements in the array

4
Enter the elements in the array

23
45
67
89
The elements in the array are

23
45

VISHNU INSTITUTE OF TECHNOLOGY


Page 18
Department of Computer Science and Engineering Resource 2023-24

67
89

7. Write a program to print the elements in an array in reverse order using recursion.

Enter the number of elements in the array

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

VISHNU INSTITUTE OF TECHNOLOGY


Page 19
Department of Computer Science and Engineering Resource 2023-24

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.

VISHNU INSTITUTE OF TECHNOLOGY


Page 20
Department of Computer Science and Engineering Resource 2023-24

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.

17. Explain the uses of final keyword with examples.

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.

VISHNU INSTITUTE OF TECHNOLOGY


Page 21
Department of Computer Science and Engineering Resource 2023-24

4. Explain functional interfaces with an example.


5. Write the differences between interface and abstract class.
6. What is a package? Explain how to create a package and how to access classes in a package
with an example.
7. Explain JAVA access modifiers in detail.
8. What is auto-boxing and auto-unboxing? Explain with an example.
9. Explain about Wrapper classes.

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.

6. Explain any 7 methods in String class with an example each.


7. Explain any 7 methods in StringBuffer class with an example each
8. a) Write the differences between String and StringBuffer.
b) Write a program to check whether the given string is palindrome or not.

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. Explain the thread life cycle with neat diagram.


4. a) How to set priority to threads? Explain with an example.
b) Write a program to illustrate the use of isAlive and join methods.
5. How to provide inter thread communication in JAVA? Write a program that illustrates
producer consumer problem.
6. List and explain types of JDBC drivers with its advantages and disadvantages.
7. a) Explain JDBC architecture.
b) Describe the steps involved in establishment a JDBC connection with database.
8. a) Explain ResultSet interface and its methods.
b) Write a program that used JDBC API to insert the data into a table.

VISHNU INSTITUTE OF TECHNOLOGY


Page 23
Department of Computer Science and Engineering Resource 2023-24

Code: 19CS3T04 R19 H.T.NO


VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)
II B. Tech I Semester Regular Examinations, APRIL-2021
Object Oriented Programming through Java
(CSE&IT)
Time: 3 hours Max. Marks: 60
________________________________________________________________________________
Note: 1. Answer all the 6 Questions
2. Each Question carries 10 Marks
3. Answer either a or b from each question
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1(a) I List and explain Java features, in detail. L1 CO1 [5M]
II Explain the architecture of Java Virtual Machine with a neat diagram. L2 CO1 [5M]
(OR)
1(b) I Demonstrate precedence rules and associativity with an example Java L2 CO1 [5M]
program.
II Write a program to demonstrate the String handling functions in java. L3 CO1 [5M]
2(a) What is class and object? Write and explain the concept of Method L3 CO2 [10M]
overloading with example program.
(OR)
2(b) I What is the importance of nested classes in java. Explain. L3 CO2 [5M]
II What is a constructor and explain the types of constructors in Java. L2 CO2 [5M]
3(a) What is inheritance? Explain the types of inheritances each with example? L1 CO3 [10M]
(OR)
VISHNU INSTITUTE OF TECHNOLOGY
Page 24
Department of Computer Science and Engineering Resource 2023-24

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.

*****

VISHNU INSTITUTE OF TECHNOLOGY


Page 25
Department of Computer Science and Engineering Resource 2023-24

Code: 19CS3T04 R19 H.T.NO


VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)
II B. Tech I Semester Supplementary Examinations, Oct - 2021
Object Oriented Programming through Java
(CSE&IT)
Time: 3 hours Max. Marks: 60
________________________________________________________________________________
Note: 1. Answer all the 6 Questions
2. Each Question carries 10 Marks
3. Answer either a or b from each question
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1(a) I How to implement type casting in Java? How it is different from primitive L2 CO1 [5M]
type conversion? Explain it with an example.
II What is an array? Explain the different ways to create and initialization L2 CO1 [5M]
of arrays in java.
(OR)
1(b) I Write any six significant differences between Procedure Oriented L1 CO1 [5M]
Programming and Object Oriented Programming.

VISHNU INSTITUTE OF TECHNOLOGY


Page 26
Department of Computer Science and Engineering Resource 2023-24

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

Code: 19CS3T04 R19 H.T.NO


VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)
II B. Tech I Semester Supplementary Examinations, March - 2022
Object Oriented Programming through Java
(CSE & IT)
Time: 3 hours Max. Marks: 60
________________________________________________________________________________
Note: 1. Answer all the 6 Questions
2. Each Question carries 10 Marks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 a Illustrate how Java achieves Abstraction. L CO [5M]
b Describe any 5 important features of Java language L CO [5M]
(OR)
2 a Write a program that reads a list of integers, and then prints the sum of L CO [5M]
the even integers and odd integers.
VISHNU INSTITUTE OF TECHNOLOGY
Page 28
Department of Computer Science and Engineering Resource 2023-24

b Write a Java program to remove a specific element from an array L CO [5M]

3 a Distinguish between constructor and method. L CO [5M]


b What is the output of the following program? Explain. L CO [5M]
class Test1 {
int x = 10;
public
static void main(String[] args)
{
System.out.println(x);
}
static
{
System.out.print(x + " ");
}
}
(OR)
4 a Is it possible to have two methods in a class with same method signature L CO [5M]
but different return types? Explain with an example.
b What do you mean by constructor overloading Java? Illustrate with L CO [5M]
example.
5 a Illustrate with an example how Java achieves run time polymorphism. L CO [5M]
Analyse the pros and cons of run time polymorphism.
b How to call a method of a subclass, if you are holding an object of the L CO [5M]
subclass in a reference variable of type super class? Illustrate with
example.

(OR)

6 a How do you create a thread? Explain with an example L CO [5M]


b Illustrate the techniques to prevent method overriding in Java L CO [5M]

7 a How do you read a CSV file in Java? L CO [5M]


b Does finally run always? On which cases finally doesn’t run? L CO [5M]
(OR)
8 a What is the right way to close the streams in Java? L CO [5M]
b What do you mean by user defined exceptions? L CO [5M]

9 a Illustrate the different ways to create String Object. L CO [5M]


b Explain multi threading. Write about thread priority. L CO [5M]

VISHNU INSTITUTE OF TECHNOLOGY


Page 29
Department of Computer Science and Engineering Resource 2023-24

(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]

*****

Code: 19CS3T04 R19 H.T.NO


VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)
II B. Tech I Semester (R19) Supplementary Examinations, Aug - 2022
Object Oriented Programming through Java
(CSE & IT)
Time: 3 hours Max. Marks: 60
________________________________________________________________________________
Note: 1. Answer all the 6 Questions
2. Each Question carries 10 Marks
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

VISHNU INSTITUTE OF TECHNOLOGY


Page 30
Department of Computer Science and Engineering Resource 2023-24

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

VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)

VISHNU INSTITUTE OF TECHNOLOGY


Page 32
Department of Computer Science and Engineering Resource 2023-24

II B. Tech I Semester (R20) - Regular Examinations, FEB/MAR – 2022


OBJECT ORIENTED PROGRAMMING THROUGH JAVA
(CSE, IT, AI & DS & CS & BS)

Time: 3 Hours Max. Marks: 70M


Note: 1. Answer all the 5 Questions
2. Each Question carries 14 Marks
3. Answer either question from each unit
UNIT – I
1 a What is meant by byte code and JVM? Briefly explain how Java is L1 CO1 [7M]
platform-independent.
b Why data type is important? What are primitive Data types in Java L2 CO1 [7M]
OR
2 a What are the OOP concepts that Java supports and how important are they? L3 CO1 [7M]

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]

*****

VISHNU INSTITUTE OF TECHNOLOGY


Page 34
Department of Computer Science and Engineering Resource 2023-24

H.T.No:
Course Code No: 20IT3T02

VISHNU INSTITUTE OF TECHNOLOGY (AUTONOMOUS)


II B. Tech I Semester (R20) - Supplementary Examinations, July – 2022
OBJECT ORIENTED PROGRAMMING THROUGH JAVA
(CSE, IT, AI & DS & CS & BS)

Time: 3 Hours Max. Marks: 70M


Note: 1. Answer all the 5 Questions
2. Each Question carries 14 Marks
3. Answer either question from each unit
UNIT – I
1 a What is JVM? Explain how it works. L1 CO1 [7M]
b Differentiate procedural language and OOP, also explain the features of L2 CO1 [7M]
OOPs.
OR
2 a What are primitive data types in java. Explain? L3 CO1 [7M]
b Write a simple program which demonstrates while and do-while. L1 CO1 [7M]
UNIT – II
3 a Explain what is a Class and what is an Object. Explain with their syntax. L1 CO2 [7M]
b What is Overloading? Explain with a simple demonstration program. L2 CO2 [7M]
OR
4 a What are access controls of class members in java. Explain. L3 CO2 [7M]
b What is inheritance? Explain different types of inheritance. L1 CO2 [7M]
UNIT – III
5 a What is a package? Explain how to create and import packages. L1 CO3 [7M]
b What is an interface? Explain about functional interfaces. L2 CO3 [7M]
OR
6 a Explain java.util package. L3 CO3 [7M]
b Can a class implement interface and extends class both at same time. L1 CO3 [7M]
Justify your answer with simple example.

VISHNU INSTITUTE OF TECHNOLOGY


Page 35
Department of Computer Science and Engineering Resource 2023-24

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]

*****

VISHNU INSTITUTE OF TECHNOLOGY


Page 36

You might also like