0% found this document useful (0 votes)
278 views16 pages

R23 OOP-java Questionbank

Uploaded by

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

R23 OOP-java Questionbank

Uploaded by

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

P.V.P.

SIDDHARTHA INSTITUTE OF TECHNOLOGY

BRANCH: Common to CSE, IT, CSE (AI&ML), Regulations: PVP23


CSE (Data Science))

Course: OBJECT ORIENTED PROGRAMMING THROUGH JAVA


Program: B. Tech

Course Code:
Year and Semester: II Year-I Sem
23CS3302/23IT3302/23AM3302/23DS3302

QUESTION BANK

UNIT I
Short Answer Questions (2 Marks Each)

Q.
Bloom’s
NO QUESTIONS CO MARKS
Level
.

Define the term "Object-Oriented Programming"


1 and list out the principles of object-oriented CO1 L1 2M
programming.

2 What is the purpose of the final keyword in Java? CO1 L2 2M

Demonstrate command line arguments by writing a


3 program that accepts two numbers from the CO1 L2 2M
command line, adds them, and prints the result.

Explain why the main method is defined as static,


4 public with an array of strings as an input CO1 L2 2M
argument.

5
Write a Java program that reads a line of text from CO1 L2 2M
the user and counts the number of vowels in the
input

What methods of the Scanner class are used to read


6 an integer and string input from the user? Explain CO1 L2 2M
with examples.

Explain the precedence and associativity of


7 arithmetic operators in Java. Evaluate the
CO1 L2 2M
expression “ 100 / 10 * 2 + 5 - 3 % 2”and determine
the result.

Explain about formatted output and write a Java


8 program that takes a user's name, age, and GPA as
CO1 L2 2M
input and prints this information in a formatted
manner.

Explain the differences between print(), println(),


9 and printf() methods in Java. Write a Java program CO1 L2 2M
to demonstrate the use of each of those methods.

Illustrate the usage of for-each loop by writing a


10 Java program to iterate over an array of integers CO1 L2 2M
and calculate the sum of all elements.

Long Answer Questions (10 Marks Each)

Q. QUESTIONS CO Bloom’ Marks


No. s Level

1 (a)
Explain the structure of a basic Java program, including the CO1 L2 5M
purpose of the main method and the importance of class
definitions. Discuss how comments and escape sequences
contribute to program readability and functionality.
(b)
Discuss how conditional statements are used in the CO1 L2 5M
program to determine the tax amount. Write a Java
program to calculate the tax on a salary. The program
should prompt the user to enter their annual salary. Use the
following tax brackets: No tax for salaries up to 2,50,000
rupees, 5% tax for salaries between 2,50,001 and 5,00,000
rupees, and 10% tax for salaries above 5,00,000 rupees.
Display the tax amount based on the entered salary.

2 (a)
Explain the concept of final variable, method and class CO1 L2 5M
using examples.

(b)
Demonstrate the use of a static variable to maintain the CO1 L2 5M
count of method calls. Write a java program to create a
logging utility that tracks how many times a particular
method is called throughout the application.

3 (a)
Explain the concepts of scope and lifetime in Java. Write a CO1 L2 5M
Java program that demonstrates the scope and lifetime of
variables.

(b)
Illustrate the difference between Procedural Oriented and CO1 L2 5M
object oriented programming.

4 (a)
What are java buzzwords? Give a brief description. CO1 L2 5M

(b)
Explain about Command line arguments. Write a java CO1 L2 5M
program to accept student marks as command line
arguments and calculate the sum, percentage and grade of
student.

5 (a)
Explain symbolic constants in Java and how they differ CO1 L2 5M
from literal constants. Write a program using symbolic and
literal constants to calculate the final price of an item after
applying a discount.

(b)
Is Java a pure object-oriented program or not? Justify your CO1 L2 5M
answer.

6 (a)
Demonstrate implicit and explicit type casting with an CO1 L2 5M
example program.

(b)
Explain about formatted input and output statements. Write CO1 L2 5M
a Java program that takes the name, quantity, and unit price
of a product as input and prints a receipt showing the total
price, formatted to two decimal places.

7 (a)
List and explain the Data types in Java program with CO1 L2 5M
examples.

(b)
Explain the difference between static and final keywords in CO1 L2 5M
Java. Illustrate your explanation with an example

8 (a)
List and explain the features of Java language. CO1 L2 5M

(b)
Write a Java program to find the first even and last odd CO1 L2 5M
number in an array of integers and print it

9
Explain the different types of tokens. Write a Java program CO1 L2 10M
that incorporates tokens to create a simple calculator that
performs basic arithmetic operations and displays the
result.

10 (a)
Explain the concepts JDK, JRE and JVM. CO1 L2 5M

(b)
Explain different iterative statements available in CO1 L2 5M
Java.Write a Java program to track book loans in a library.
The program should prompt the user to enter the following
for each borrowed book:

● The number of books borrowed.

● The number of days each book was borrowed.

● The number of days each book was returned before


the due date.

Assume that the user will be charged 1 rupee per day for
borrowing each book. If a book is returned before its due
date, a 10% discount will be applied to the total charge for
that book. Calculate and display the total charge for all
books after applying any discounts.

UNIT II
Short Answer Questions (2 Marks Each)

Q.
Bloom’s
NO QUESTIONS CO MARKS
Level
.

1 What is the purpose of the public and private access CO2 L2 2M


modifiers in Java classes?

2 What is a constructor in Java? How is it different from a CO2 L2 2M


method?

3 What is the String class in Java? How does it differ from the CO2 L2 2M
StringBuilder class?

4 List and briefly describe two methods of the String class CO2 L2 2M
that can be used to modify a string.

5
Explain the term object. Write a simple Java program that CO2 L3 2M
declares a class “Book” with attributes “title” and “author”.
Create two Book objects and demonstrate how to assign the
values of one Book object to another and print their
attributes.

What “this” pointer? Write a Java class “Employee” with CO2 L3 2M


6 attributes “name” and “salary”. Use “this” keyword within a
method to display the current object’s attributes.

Create a Java class “Product” with private “productCode”, CO2 L3 2M


7 “price” attributes, and use getter and setter methods to
access and modify these attributes in a main program.

8 What is method overloading? Write a simple java program CO2 L2 2M


to demonstrate method overloading.

9 Explain how the “charAt” method works in the String class. CO2 L2 2M
Provide a simple example.

Write a Java program that takes a string input from the user CO2 L3 2M
10 and replaces all occurrences of a specified character with
another character. Print the modified string.

Long Answer Questions (10 Marks Each)

Q. NO. Bloom’s
QUESTION CO MARKS
Level

1 (a)
Create a Java program that reads a string from the user
and performs the following operations: find the length
of the string, convert it to uppercase, and search for a CO2 L3 5M
specific substring. Use String methods to accomplish
these tasks and print the results.
(b)
What is constructor overloading? Write a java program
CO2 L3 5M
to demonstrate constructor overloading

2
Explain the concept of class declaration and modifiers
in Java. Write a Java program to define a class
“Library” with public and private members.
CO2 L3 10M
Demonstrate the use of public, protected, and private
access modifiers by creating a Library object and
accessing its members from another class.

3
What is a Nested class? Explain the different types of
nested classes. Write a program to demonstrate each of CO2 L3 10M
the nested class types with an example.

4
Explain the “CharSequence” interface in Java. What
are its key methods, and how does it relate to other
classes such as String, StringBuilder, and
CO2 L3 10M
StringBuffer? Write a Java program using the
“CharSequence” interface to display the sub-sequence
of the taken string.

5
Explain the “StringBuffer” class in Java. How does it
differ from the String class in terms of immutability
and performance? What are the key methods provided CO2 L2 10M
by “StringBuffer” for manipulating strings? Explain
with an example.

6
Discuss how class objects can be used as parameters in
methods. What are the advantages of passing objects as
parameters? Write a Java class “Rectangle” with
methods to calculate the area and perimeter. Create
CO2 L3 10M
another class “AreaCalculator” with a method that
takes a “Rectangle” object as a parameter and
calculates the area. Demonstrate the usage of this
method in a main program.
7
Explain the purpose of constructors in Java and the
difference between a default constructor and a
parameterized constructor. Write a Java class “Book”
CO2 L3 10M
with both a default constructor and a parameterized
constructor. Demonstrate how to create Book objects
using both constructors and initialize their attributes.

8
Discuss the difference between passing arguments by
value and passing arguments by reference in Java.
Write a Java program with methods that demonstrate
CO2 L3 10M
passing primitive types and object references. Show
how modifications to parameters affect the original
values.

9 (a)
Explain the role of the “this” keyword in Java. How
does it help in accessing instance variables and
CO2 L3 5M
methods? Write a java program to demonstrate “this”
keyword.

(b)
What is recursion? How does a recursive method work,
and what are the key considerations when
CO2 L3 5M
implementing recursive methods? Write a Java method
to compute the Fibonacci sequence using recursion

10
Explain the “String” class in Java and its role in string
manipulation. List and explain various methods of the
“String” class for extracting characters, comparing
CO2 L3 10M
strings, searching within strings, and modifying
strings. Write a Java program that demonstrates the
usage of these methods.

UNIT III
Short Answer Questions (2 Marks Each)
Q. Bloom’s
QUESTIONS CO MARKS
NO. Level

1 Demonstrate about multidimensional arrays in java. CO2 L2 2M

2 Compare and contrast abstract class and interface. CO2 L2 2M

3 Describe an interface? How does it support multiple inheritance CO2 L2 2M


in java

4 Explain about the super keyword with examples. CO2 L2 2M

5 Discuss whether java supports multiple inheritance? Justify your CO2 L2 2M


answer.

6 Explain how you print the number of elements in an array? CO2 L3 2M

2M
7 Explain the different methods of declaring and initialization of CO2 L2
arrays

8 Explain about final keyword CO2 L2


2M

9 Explain about Inheritance of interfaces. CO2 L2 2M

10 Describe various sorting techniques. CO2 L2 2M

Long Answer Questions (10 Marks Each)

Q.
Bloom’
NO QUESTIONS CO Marks
s Level
.
1 (a) CO2 L3 5M
Develop a program to perform matrix multiplication.
(b) Explain about the Object class in Java with its methods. CO2 L2 5M

2 (a) Develop a Java Program to implement Binary Search CO2 L3 5M


Mechanism
(b) Differentiate implements & extends keywords with CO2 L3 5M
suitable examples.
3 (a) CO2 L3 5M
Differentiate abstract classes & Interfaces.
(b) Illustrate The Use of Super keyword with suitable CO2 L3 5M
example.
4 (a) CO2 L3 5M
Develop a Java Program to implement Bubble Sort
(b) CO2 L3 5M
Explain about Dynamic Method Dispatch with an example.
5 (a) Explain about Arrays class and its methods CO2 L3 5M
(b) Explain about different types of inheritance with examples CO2 L2 5M

6 Develop a java program to check whether the given 2D CO2 L3 10M


array has non zero elements in the diagonal position and
zeros in the non-diagonal positions .
7 (a) What is method overriding? Illustrate the concepts of CO2 L3 5M
method overriding and constructor overriding.

(b) Develop a Java program to interchange the rows and CO2 L3 5M


columns of a given matrix.
8 (a) Explain the member access mechanism in the inheritance CO2 L3 5M
with an example.
(b) How can you extend one interface by the other interface? CO2 L3 5M
Discuss
9 (a) Develop a program to demonstrate the use of arrays as CO2 L3 5M
vectors.
(b) Explain the procedure to call super class members with an CO2 L3 5M
example.
10 Create an interface Shape with an abstract method draw(). CO2 L3 10M
Create two classes, circle and rectangle which implements
interface Shape. Draw() should print the text indicating its
shape. Create a reference to the shape and object of either
circle or rectangle depending on the user ‘s choice and call
the method draw().

UNIT IV
Short Answer Questions (2 Marks Each)

Q. QUESTIONS CO Bloom’s Marks


NO. Level

1 List some of the checked exception classes CO1 L2 2M


in Java.

2 What is the use of CLASSPATH in Java? CO1 L2 2M

3 What is an unchecked exception? CO1 L2 2M

4 Differentiate throw and throws in exception CO1 L2 2M


handling.

5 How can you obtain the Class object for a CO1 L2 2M


specific class in Java?

6 Illustrate unboxing by converting an Integer CO1 L2 2M


object to an int.

7 Provide an example of autoboxing for CO1 L2 2M


converting an int to an Integer.

8 Write a program that calculates the square CO3 L3 2M


root of a given positive number using
Math.sqrt().

9 For the primitive data types in Java (e.g., CO1 L2 2M


int, double, char) list their corresponding
wrapper classes?

10 Illustrate the class hierarchy of the CO1 L2 2M


Throwable class.

Long Answer Questions (10 Marks Each)

Q. Bloom’s
QUESTIONS CO Marks
NO. Level

1 (a) Explain the behaviour of different access CO3 L3 5M


specifiers in packages.

(b) Develop a java program to handle multiple CO3 L3 5M


exceptions like Division by zero and Number
Formatted Exception.

2 (a) What is an exception? Explain exception CO1 L2 5M


handling mechanism with an example.

(b) Develop a Java program by defining, creating CO3 L3 5M


and accessing a package

3 (a) What is the purpose of the java.lang package in CO1 L2 5M


Java? Which classes are automatically imported
from this package?

(b) Explain the role of the Object class in Java. Why CO1 L2 5M
is it considered the root class for all other
classes?

4 (a) Develop a java program that demonstrates how CO3 L3 5M


certain exception types are not allowed to be
thrown.

(b) Suppose you have a package named CO3 L3 5M


com.example.myapp. How would you import a
class named MyClass from this package into
another Java file?

5 (a) Develop a java program that illustrates the CO3 L3 5M


application of multiple catch statements

(b) How can you write data to a file using CO3 L3 5M


FileOutputStream? Provide a code snippet
demonstrating the process.

6 (a) Demonstrate the class Throwable with the help of CO3 L3 5M


a Java program.

(b) Compare character streams (Reader and Writer) CO3 L3 5M


with byte streams (InputStream and
OutputStream). When would you choose one
over the other?

7 (a) Give a brief description about the role of wrapper CO1 L2 5M


classes in java.
(b) Write a program that reads integers from the user CO3 L3 5M
using Scanner and calculates their sum.

8 (a) Write a program to demonstrate the working of CO3 L3 5M


user defined exceptions.

(b) Describe the significance of the Math class. What CO1 L2 5M


mathematical operations can you perform using
its static methods?

9 (a) Discuss the importance of exception handling CO3 L3 5M


when working with files. What exceptions can
occur during file I/O operations?

(b) Describe the role of standard I/O streams CO1 L2 5M


(System.in, System.out, and System.err) in Java.
How can you read user input from the console?

10 (a) Write a try-catch block that handles exceptions CO3 L3 5M


when opening a file for reading.

(b) What is the purpose of byte streams in Java I/O? CO1 L2 5M


Explain with an example of reading data from a
file using FileInputStream.

UNIT V
Short Answer Questions (2 Marks Each)

Q. Bloom’s
QUESTIONS CO MARKS
NO. Level

1 2M
List the states in the lifecycle of a Thread? CO4 L4

2 2M
What is context-switching in multi-threading? CO4 L1

Explain what is a thread.


3 2M
CO4 L2

4 2M
Distinguish between a thread and a process? CO4 L4
List interfaces used in Java Collections Framework.
5 2M
CO4 L2

Summarize ArrayList in Java?


6 2M
CO4 L2

7 2M
Develop a Java Program to create a List in Java? CO4 L2

8 2M
Show the generic representation of Queue Interface CO4 L1

9 2M
List out the operations on sets. CO4 L4

10 Construct a Java method to Find the element exists 2M


CO4 L3
or not in a HashSet.

Long Answer Questions (10 Marks Each)

Q. Bloom’s
QUESTIONS CO Marks
NO. Level

1 (a) Analyze different ways of implementing a thread? 5M


CO4 L4
(b) Discover How threads communicate with each
5M
other? CO4 L4
2 (a) Illustrate Priorities in Multithreading 5M
CO4 L2
(b) Examine the threads to prevent concurrency
5M
problem. CO4 L4
3 (a) Distinguish sleep() and suspend() methods in
multithreading with example code. CO4 L4 5M

(b) Construct a Java program to create a


multithreading using runnable interface CO4 L3 5M

4 (a) Explain the creation of a thread using extending a 5M


thread class. CO4 L2
(b) Compare a List with Set in Java
CO4 L4 5M
5 (a) Conclude a priority queue in Java? How to declare
it? Show with an example code. CO4 L4 5M

(b) Explain the hierarchy of the Collection framework


in Java. CO4 L2 5M

6 (a) Explain about HashSet.


CO4 L2 5M
(b) Classify in how many ways we can get the elements
using index from a HashSet CO4 L4 5M

7 (a) Construct a program to iterate the list using the


CO4 L3 5M
lambda expression.
(b) Develop a program in java to get the values
CO4 L3 5M
present in a HashSet
8 (a) Examine how to set and get elements to a list?
5M
Show with an example code. CO4 L4
(b) Examine how to insert and delete elements into an
CO4 L4 5M
existing queue? Discuss.
9 (a) Construct a Sample program to illustrate the sets. 5M
CO4 L3
(b) Develop a java program to ignore duplicate
CO4 L3 5M
elements using hashset.
10 (a) List the constructors of a Priority queue. Show
CO4 L4 5M
with an example code.
(b) List the ArrayList methods of java. Explain any
CO4 L4 5M
two with syntax and example
Course Coordinators:

1. Dr. P. Sai Kiran (CSE)


2. Dr. Y. Suresh (IT)
3. Ms. D. Sreelakshmi (CSE)
4. Mr. B. V. Satish Babu (IT)
5. Mr. A. Prashant (CSE)
6. Mr. B. Kalyan Chakravarthy (CSE(AI & ML) & CSE(DS))
Head, Department of CSE Head, Department of IT

Head, Department of CSE(AI & ML) Head, Department of CSE(DS)

You might also like