Java Model Question 3
Published by: Anil K. Panta
Section A – Very Short Answer Questions
Attempt all questions. [10×2 = 20 Marks]
Mention any two problems with procedure-oriented programming.
Define the term “object” in the context of Java.
What is the purpose of access specifiers in Java?
Define constructor overloading.
Explain try, catch and finally blocks?
Define FileInputStream and mention its purpose.
Write two differences between JFrame and JPanel.
What is type safety in the context of generics?
Write a use case where static variables would be preferred.
What is the significance of the break and continue statements?
Section B – Descriptive Answer Questions
Attempt any five questions. [5×10 = 50 Marks]
Write a Java program to accept names of 5 students and display them in reverse order.
Create a class Rectangle with length and breadth as attributes. Use a constructor to initialize the values and a method to calculate and return the area.
Define and explain encapsulation. Write a program using getter and setter methods for class Employee.
Describe the Java Exception. Write a program that throws a user-defined exception if age < 18.
Explain the working of FileOutputStream and ObjectOutputStream. Write a program to serialize an object.
Describe multiple inheritance using interfaces with a suitable example. How is ambiguity resolved in Java when a method is inherited from two interfaces?
Section C – Long Answer Questions
Attempt any two questions. [2×15 = 30 Marks]
a. What is a layout manager? Explain any two different types of layout managers in Java Swing.
b. Create a Student Registration form using Swing (as shown in the figure).
Explain dynamic method dispatch with a real-world example. How does Java handle method calls at runtime?
Explain generics and their importance. Write a generic method that swaps two elements in an array. Demonstrate its use with both integer and string arrays.