Java Question Bank
Java Question Bank
2 Marks Questions
5 Marks Questions
10 Marks Questions
10
5
2
2
2
5
5
2
5
10
2
2
5
2
2
5
2
5
5
5
5
10
5
2
Module 2
2 Marks Questions
5 Marks Questions
10 Marks Questions
[1] Discuss different access specifier of java. Explain each with examples.
[2] a) Explain public static void main(String args[]) in Java.
b) Explain each token in the statement:
System.out.println(“Hello Java”);
[3] Write a program that reads ten numbers through command line argument, computes their
average, and finds out how many numbers are above the average.
[4] Explain different iterators used for accessing the elements,with examples.
[5] Discus operators and control statements in Java in detail.
[6] Write a program that defines a class that represents a complex number.Write a method in
the class that returns the magnitude or modulus of the complex number on which it is called.
REFERENCE: E. Balaguruswami, Programming with Java, 6th edition
Chapter 4,5,6
2
2
5
2
5
2
2
2
10
5
5
5
2
10
10
10
10
10
5
10
5 +5+5+5
10
10
10
10
STUDY MATRERIAL
1) What are the different ways to implement method overloading?
2) Compare and contrast overloading and overriding methods.
3) Explain the significance of using Interface.
4) Explain the purpose of abstract classes and how they differ from concrete classes.
5) Discuss the role of abstract methods in abstract classes and how they are implemented in concrete
subclasses.
6) Discuss the role of the @Override annotation in method overriding.
7) Describe the concept of strings in object-oriented programming (OOP) and explain how they are
represented as objects.
8) Explain String Tokenizer with an example.
9) Explain the need for StringEquals function in java with suitable example.
10) Explain the term immutable String in java with suitable example.
11) Can you call one constructor from another if a class has multiple constructors?
12) Explain the syntax of BufferedReader object creation.
13) Can we override a method by using the same method name and arguments but different return
types?
14) Explain the syntax of BufferedReader object creation.
15) Can we override a method by using the same method name and arguments but different return
types?
16) In a class implementing an interface, can we change the value of any variable defined in the
interface?
17) Can we make constructors static?
18) Can we use this() and super() both in a same constructor?
19) Distinguish between private and protected access modifier with suitable examples.
20) Explain var-args array.
21) Write down the significance of static keyword.
22) Distinguish the use of extends and implements.
23) What happens if the constructors are defined as private?
24) If two interfaces contain method with same signature and what happen if a class inherits both?
25) Is it possible to override super-class constructor? Why?
26) Explain "Is-A" relationship in inheritance.
27) Explain "HAS-A" relationship in inheritance.
28) What is method overriding and how does it differ from method overloading in Java?
29) When can a method in super class be prevented from being overridden by a method in subclass?
30) Can we declare the static variables and methods in an abstract class?
5 Marks Questions
10 Marks Questions
REFERENCE: STUDY MATRERIAL
1) Discuss the difference between start() and run() methods by demonstrating through a
Multithreaded Java program. Justify your observations.
2) Design an abstract class shape having two methods calculate_area() and display(). Create
rectangle, triangle, and ellipse classes by inheriting the shape class and overriding the
above methods to suitably implement rectangle, triangle, and ellipse classes.
3) Evaluate the design of a banking application in Java that uses abstract classes and interfaces
to model various account types. Analyse the role of abstract classes in providing common
behaviour among account types and interfaces in defining a contract for account operations.
4) Generate a class where a Company manufactures Vehicles, which could be a Helicopter, a
Car, or a Train depending on the customer’s demand. Each Vehicle instance has a method
called move, which prints on the console the nature of movement of the vehicle. For
example, the Helicopter Flies in Air, the Car Drives on Road and the Train Runs on Track.
Write a program that accepts input from the user on the kind of vehicle the user wants to
order, and the system should print out nature of movement. Implement all Java coding best
practices to implement this program.
5) Develop a java code to create Thread by implementing the Runnable interface. Write a java
program to implement the yield( ) method in thread programming.
6) Design a Java program to display the car no., model, colour and price of a car using class
and object concept.(use Scanner class).
7) What is array of objects? Describe the use of Access Modifiers in Java? Draw a table
showing the scope of accessibility? Justify: I. Why we declare main () method as public
and static member. II. Why we generally declare constructor as public member. III. Why
there is no destructor in java.
8) Differentiate between abstract class and Interface. The abstract Vegetable class has three
subclasses named Potato, Brinjal and Tomato. Write an application that demonstrates how
to establish this class hierarchy. Declare one instance variable of type String that indicates
the colour of a vegetable. Create and display instances of these objects. Override the
toString() method of Object to return a string with the name of the vegetable and its colour.
2
2
2
2
2
2
10
10
10
10
10
10
10
10
10
10
5
5
10
10
10
2
5
5
10
10
STUDY MATRERIAL
1) What are the different types of exceptions?
2) Compare between “extends Thread” and “implements Runnable” options. 3)
Describe the concept of thread scheduling in Java.
4) What is the main advantage of using threads in Java applications?
5) What is a thread in Java?
6) Examine the purpose of Static methods and static variables.
7) What is thread based multitsking?
8) What is process based multitasking ?
9) Write down the difference between Concat method and + operator to join strings?
10) In multi-threading how can we ensure that a resource isn‟t used by multiple threads
simultaneously?
11) Distinguish between private and protected access modifier with suitable examples.
12) What is default exception handler?
13) Distinguish between throw and throws.
14) What happens if matching exception type is not found in catch blocks? Explain.
15) Discuss the use of join() in multithread programming.
16) Write a statement that moves a thread to blocked-state.
17) Write a program where one interface inherits another one.
18) Compare Garbage collection and finalize method
19) Write a program where one interface inherits another one.
20) Write a statement that moves a thread to blocked-state.
5 Marks Questions
10 Marks Questions
REFERENCE: E. Balaguruswami,
Programming with Java, 6th edition Chapter
11, 12, 13
2
2
2
2
2
2
2
2
2
5
2
10
2
2
2
5
5
5
5
5
5
10
10
Module 5
2 Marks Questions
1) Implement a method in Java that takes a HashSet as input and removes all duplicate
elements from it.
2) Develop a utility class that provides methods for merging and sorting multiple
ArrayLists efficiently.
3) What are streams? Write any two methods of character stream classes. What is the
use of ArrayList Class? State any three methods with their use from ArrayList.
REFERENCE: E. Balagurusami,
5
10
Module 6
2 Marks Questions
1) Explain the term collection API ,collections and collection.
2) What does unified mean 3) What Is a Model?
4) Write down about the goals of UML?
5) What is static view?
6) What is Design View?
5 Marks Questions
10 Marks Questions
2) The Library Loan System manages the loans and circulation of library resource
material such as books, journals and audiovisuals. Students and faculty enjoy
membership at the library. During checkout, the LLS obtains the student or faculty
ID. Resource materials can be checked out (i.e. borrowed) for a duration of 2 weeks.
A fine of 1 rupee a day is imposed on overdue materials. Draw a detailed Class
diagram
Module 7
2 Marks Questions
1) Explain the purpose and application of the AWT (Abstract Window Toolkit) package in Java,
highlighting its usage and relevance within the Java programming environment.
2) Create a diagram depicting the applet hierarchy in Java, specifically indicating the superclass name
of the Applet class.
3) What are the life cycle methods of android activity?
4) Differentiate between components and Containers in Swing.
5) What is the super class for all applets?
6) Why do applet classes need to be declared as public.
5 Marks Questions
10 Marks Questions
1) Create a GUI using the swing package containing one text field, button, and label.
Also, incorporate the code against the button click event to fetch the user-given text
from the text field and display the same in the label.
2) Design an applet program in Java to exhibit graphical elements such as a 'Rectangle,' 'Line,'
and 'Arc.' Elaborate on the sequential steps required for compiling and executing the
applet program effectively(Must mention the syntax for compilation and the execution
process).
3) Draw and explain Android Architecture in detail?
REFERENCE: E. Balagurusami,
Chapter 14
2
2
2
2
2
2
2
2
2
10