0% found this document useful (0 votes)
18 views

Question Bank - OOPS

The document is a comprehensive question bank for an OOPs course using Java for 3rd semester students. It includes short and long answer questions divided into four units covering various topics such as Java programming concepts, object-oriented principles, multithreading, and applet programming. Each unit contains practical programming tasks and theoretical questions to assess students' understanding of Java and its applications.

Uploaded by

mrdeepakkumar787
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)
18 views

Question Bank - OOPS

The document is a comprehensive question bank for an OOPs course using Java for 3rd semester students. It includes short and long answer questions divided into four units covering various topics such as Java programming concepts, object-oriented principles, multithreading, and applet programming. Each unit contains practical programming tasks and theoretical questions to assess students' understanding of Java and its applications.

Uploaded by

mrdeepakkumar787
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/ 5

Question Bank – OOPS Using Java – 3rd Semester

Unit – I
Short Answer Questions:

1. Describe the uses of parseInt() in Java programming.


2. Write the code to check the biggest among three numbers using the ternary operator.
3. Why is Java called a platform-independent language?
4. Why is the main() method always declared as static in Java?
5. Write any two differences between C++ and Java.
6. What is casting? Explain the need for typecasting with examples.
7. What is a jagged array? Explain with an example.
8. Assume A[2][3] is a matrix. Write to code and create a transpose matrix of it.
9. Write a program to initialize an integer array and print the sum and average of the
array.
Long Answer Questions:

1. Explain all the characteristics of “Object-oriented programming”.


2. Write a Java program to read a number (using Scanner class) and test whether it is
prime or not.
3. Briefly explain all the features of Java.
4. Write a program to read a number say ‘n’ (using command line arguments) and
generate a Fibonacci series up to ‘n.
5. Differentiate between the Scanner class and Buffered Reader class in Java with a
suitable example.
6. Describe JVM and explain and draw the Architecture of JVM.
7. Write a Java program to create and display unique three-digit numbers using 1, 2, 3,
and 4 and print a total count of three-digit numbers.
8. Write a Java program to convert a binary number to a decimal number.
9. Demonstrate a Java program to accept a number at run time using scanner class and
check whether the given number is Armstrong or not.
10. Write a Java program to read a square matrix of 3x3 order and print the sum of all the
elements of each row.
11. Write a program to read and convert seconds to hours, minutes, and seconds.
12. Write a program to check if the program has received command line arguments or not.
If the program has not received arguments then print "No Values", else print all the
values in a single line separated by ,(comma).
13. Write a program to receive a color code from the user (an Alphabhet). The program
should then print the color name, based on the color code given. The following are the
color codes and their corresponding color names. R->Red, B->Blue, G->Green, O-
>Orange, Y->Yellow, W->White. If color code provided by the user is not valid then
print "Invalid Code".
14. Write a program to print first 5 values which are divisible by 2, 3, and 5.
15. Write a program to initialize a character variable in a program and print 'Alphabhet' if
the initialized value is an alphabet, print 'Digit' if the initialized value is a number, and
print 'Special Character', if the initialized value is anything else.
16. Write a program to print the sum of all the digits of a given number.
17. Write a program to find the sum of digits of a number until the sum becomes a single
digit.
18. Write a program to initialize an integer array with values and check if a given number
is present in the array or not. If the number is not found, it will print -1 else it will print
the index value of the given number in the array.

Unit – II
Short Answer Questions :

1. Write a Java program that will return the first half of the string, if the length of the
string is even. It should return null if the length of the string is odd.
2. Write a program to receive an integer number as a command line argument, and print
the binary, octal, and hexadecimal equivalent of the given number.
3. Differentiate between static and run-time polymorphism with an example.
4. List out the differences between “abstract class” and “interface”.
5. What is a marker interface? List out any two marker interfaces.
6. Differentiate between “implements” and “extends” keywords.
7. What are the steps involved to create and import a package ?
8. Explain the difference between length and length() with suitable example.
Long Answer Questions :

1. What is the role of the constructor? Explain constructor overloading with an example .
2. Define static data member in Java and demonstrate a suitable example to count the
number of objects constructed using static data members.
3. Explain any three usages of “this” keyword with an example of each.
4. What is method overloading in Java? Write a program to overload area() method, which
will calculate the area of a rectangle and square.
5. Create a class called Calculator with the following methods: 1) A static method called
powerInt(int num1,int num2) This method should return num1 to the power num2. 2)
A static method called powerDouble(double num1,int num2). This method should
return num1 to the power num2. Invoke both methods and test the functionalities.
6. Write a program to create a base class Fruit with name, taste, and size as its attributes.
Create a method called eat() which describes the name of the fruit and its taste. Inherit
the same in 2 other classes Apple and Orange and override the eat() method to represent
each fruit taste.
7. Demonstrate “Autoboxing” and “Unboxing” with suitable examples.
8. Explain the concept of “Dynamic method dispatch” with a suitable example.
9. List out all the usages of super keyword with suitable example.
10. Write a program to read an input String from the user and parse it to an integer, if it is
not a number it will throw NumberFormatException, Catch it, and print "Entered input
is not a valid format for an integer." or else print the square of that number
11. Explain the working principle of “nested try-catch” with a suitable example.
12. Write a program to create a package called test package. Define a class called
foundation inside the test package. Inside the class, you need to define 4 integer
variables: var1 with private access modifier, var2 with default access modifier, var3
with protected access modifier, var4 with public access modifier. Import this class and
packages in another class. Try to access all 4 variables of the foundation class and see
what variables are accessible and what are not accessible.
13. Explain the following with an example: i) super ii) final
14. What is the difference between an Error and an exception? Write a Java program to
illustrate the usage of multiple catch handlers.
15. Differentiate between String and StringBuffer class. Write a program to test whether a
string is palindrome or not.
16. Explain the following methods used in SringBuffer class with examples.
i)append()
ii) insert()
iii) replace()
iv) delete()
v) length()
17. Write a Java Program to Find the Frequency of Character in a String.
18. What is multiple inheritance? How can we achieve multiple inheritance in Java, explain
with an example.

Unit – III
Short Answer Questions :

1. Write a program to create a thread that prints 1 to 10. After printing 5, there should be
a delay of 5000 milliseconds before printing 6.
2. Explain the role of wait(), notify() and notifyAll() methods?
3. What is a thread scheduler, and how is it related to thread priority?
4. Explain the need for “static synchronization” in multithreading.
5. What is a daemon thread? How do you create a daemon thread in Java?
6. Write down the syntax to open a file in reading mode. List out the possible exceptions.
7. How many ways a thread can be created? Explain with and example.
8. Write a program to read a sentence and display it by inserting * in place of space.
Long Answer Questions :

1. Write a program to create two threads, one thread to display all even numbers between
1 & 20, and another thread to display odd numbers between 1 & 20. Note: Display all
even numbers followed by odd numbers.
2. Differentiate among sleep(), yield(), and join() method.
3. Create a class called Employee with properties name(String), department(String),
designation(String), and Salary(double). Create respective getter and setter methods
and constructors (no-argument constructor and parameterized constructor) for the
same. Create an object of the Employee class and save this object in a file called "data"
using serialization. Later using deserialization read this object and print the properties
of this object.
4. Explain the life cycle of a thread with a neat diagram.
5. What is the significance of the “anonymous inner class” ? Explain with an example.
6. Write a program to copy the contents of a file “source.txt” into “destination.txt”. ( Note:
All possible exceptions should be handled.)
7. What is synchronization? Explain the role synchronized method with a suitable
example.
8. Explain the role of InputStream and OutputStream classes. Write a program to count
the total characters present in a file (excluding the spaces).
9. Write down the syntax of nested try block. Explain with suitable example by using
exception classes ArithmeticException and ArrayIndexOutOfBoundsException.
10. Explain thread priorities with a suitable example.
11. What do you mean by deadlock? Explain with an example.
12. What is user user-defined Exception in Java? WAP to accept student age and check
whether he is eligible to vote or not? Show an appropriate message when the age is not
eligible.

Unit – IV
Short Answer Questions :

1. Describe the methods (1) setBackground( ) (2) setForeground( ) with their syntax.
2. Differentiate between “applet” and “application”.
3. What is the advantage of “Adapter” class over “Listener” interface?
4. What is the difference between the paint() and init() method?
5. Write down the syntax and usage of setBounds() and setSize() method in AWT.
6. Explain the role of the Frame class in AWT programming.
7. Write a program to display “Hello Friend” using an applet.
8. Write a program to set parameter using applet and display the values of parameters
using an applet.
9. What is the difference between “getDocumentBase()” and “getCodeBase()” method.
10. List out any four methods (along with syntax and usage) of Graphics class.
11. List out the basic differences between checkbox and radio button. Write down the steps
to create three checkboxes (CSE,CST,CSA) and two radio buttons (MALE,FEMALE).
Long Answer Questions :

1. Write a Java program to implement the MouseMotion Adapter.


2. How applets are different from applications? Explain the life cycle of an applet.
3. Write a Java program to count the total number of words and characters entered in the
TextField.
4. Write a program to draw a smiley using the applet.
5. Write a program to explain event handling related to a Radio button.
6. List out the methods used to display an image in an applet. Illustrate with an example.
7. Write a program to create two checkboxes “JAVA” and “PYTHON”. Design two labels
that will display checkbox contents when selected.
8. Write a program to illustrate event handling using the Choice box.
9. Write a program to input 2 numbers into two TextFields. Display the sum of them in
another TextField when the button is clicked.
10. Write a program to display an image using an applet.
11. Write a program to illustrate all the methods of the WindowListener interface.
12. Write a program to draw a circle on the window each time the mouse is clicked.
13. Write an applet program to implement the painting application using the
MouseMotionListener interface.
14. Write a program to draw the following in an applet
a. rectangle (filled with blue color)
b. oval (filled with red color)
c. elliptical arc (green color)

You might also like