Java Model Question 2
Published by: Anil K. Panta
Section A:
Very Short Answer Questions
Attempt all questions. 10×2=20
1. Differentiate between OOP and POP. (Unit I)
2. Define the role of JDK and JVM. (Unit II)
3. Illustrate the significance of “this” pointer. (Unit III)
4. Describe lambda function. (Unit IV)
5. Compare errors and exceptions. (Unit V)
6. List the FileInputStream. (Unit VI)
7. Write the importance of Swing in GUI. (Unit VII)
8. Identify the advantages associated with Generics. (Unit VIII)
9. Summarize the definition of a primitive data type. (Unit II)
10. Define abstraction with syntax. (Unit IV)
Section B:
Descriptive Answer Questions
Attempt any five questions. 5×10=50
11. Explain the different types of operators used in Java with examples. (Unit II)
12. (Unit III)
a) Give explanations of two access specifiers in Java with examples.
b) Explain static member with suitable example.
13. Write a program to take any six number from the user and find the min, max, and average of the number. (Unit II)
14. (Unit IV)
a) Explain method overloading and describe the way it is implemented in Java.
b) Write a Java program to demonstrate method overriding.
15. Write a Java program using the concept of classes and constructors to represent and add two time values. Each time should be defined in terms of hours, minutes, and seconds. Your program should include:(Unit III)
● A class Time with three data members: hh, mm, and ss.
● A parameterized constructor to initialize the time values.
● A method addTime() to add two Time objects and return the result as a new Time object.
● A method showResult() to display the result in a proper format.
16. Write a program that reads a user's name and age as input from the console and stores this information in a text file. (Unit VI)
Section C:
Long Answer Questions
Attempt any two questions. 2×15=30
17.
a) Explain how generic classes are implemented.
b) Illustrate a program to handle null pointer exception.
18. What is constructor? Describe its types with suitable examples.
19. Write a GUI based program using Swing for the following:
a. A text field where a user is allowed to enter any number value.
b. Three buttons Up, Down, and Reset. Up button increments the value by 1. Down button decreases the value by 1 and Reset button resets its value to 0.