Java Model Question 1

Java Important Model Question

Java Model Question 1

Java Model Question 1

Published by: Anil K. Panta

Model Question 1 


Section A: 

Very Short Answer Questions 

Attempt all questions. 10×2=20 


1. List the features of OOP. 

2. What do you mean by Class & Object? 

3. What are various operators in Java? 

4. How do you run a java class named Student.java with necessary steps? 

5. Define static keyword. 6. Why do we need interface in Java? 

7. Write down any two examples of exceptions in Java. 

8. What is a package? Give an example of a built-in Java package. 

9. How can we read file name abc.txt? 

10. What are the various containers supported by Java Swing?

 

Section B: 

Descriptive Answer Questions 

Attempt any five questions. 5×10=50 


11. Explain the limitations of procedure-oriented programming (POP) and how OOP addresses them. Also write a Java program to insert elements in an array and display the largest element. 

12. What are constructors in Java? Explain with example about the concept of types of constructors.

13. Differentiate between Error & Exception. Explain the try-catch-finally mechanism with java code example. 

14. Explain with example how can we read the graphic contents of file & write it to another file? 

15. Write a Java program using a class and parameterized constructor to represent a Student with attributes like roll number, name, marks of 3 subjects and percentage. Include methods to calculate percentage and display the result if the student is passed or failed. (If percentage>=45 pass otherwise fail. Take input details of 2 Students from the user and use a constructor to initialize those values). 

16. Write short notes on any two: 

a) Lamda Function 

b) Abstract Class 

c)Generic Methods 


Section C: 

Long Answer Questions 

Attempt any two questions. 2×15=30 


17. Write a Java program using the concept of classes and constructors to represent and add two height. Each height should be defined in terms of feet and inch. Your program should include: 

● A class Height with two data members: ft and in. 

● A parameterized constructor to initialize the height values. 

● A method addHeight() to add two Height objects and return the result as a new Height object. 

● A method showResult() to display the result in a proper format. 

● Take the input of two height values from the user. 

18. What is Inheritance? How hybrid inheritance is achieved in Java? Write a Java program to demonstrate hybrid inheritance. 

19. Develop a GUI based program using Swing components for the following: 


a) Enter the NPR amount using a TextField 

b) Use a button which on click displays the USD value in new Label for the entered NPR value. (Exchange rate: 1USD=132.5NPR)

We will get back to you via email or phone call