JNTU
JNTU B.Tech II JAVA PROGRAMMING Previous Question Paper (March - 2022 - R13)
Answer any five questions. All questions carry equal marks.
Main
What are the drawbacks of procedural languages? Explain the need of object-oriented programming with suitable program.
Answer
Procedural programming languages focus on a step-by-step execution of functions, which leads to several drawbacks: data is often global and easily accessible, making it vulnerable to accidental modification; code reusability is limited because functions are tightly coupled to data structures; and maintaining or scaling large, complex systems becomes difficult as the code becomes monolithic and hard to debug.
Object-oriented programming (OOP) addresses these issues by bundling data and methods into objects, promoting encapsulation, inheritance, and polymorphism. This improves modularity, security, and maintainability.
Example in Java:
class Calculator { private int result; public void add(int a, int b) { result = a + b; } public int getResult() { return result; } } public class Main { public static void main(String[] args) { Calculator calc = new Calculator(); calc.add(10, 20); System.out.println(calc.getResult()); } }Does Java support multi way selection statement? Justify your answer.
Answer
Yes, Java supports multi-way selection through the switch statement. This construct allows a program to evaluate an expression and branch to one of several execution paths based on matching constant values.
The syntax is as follows:
The switch statement is more efficient than a long chain of if-else-if statements when checking a single variable against multiple discrete values. Since Java 7, the expression can also be of type String, providing greater flexibility in control flow logic.
What are the primitive data types in Java? Write about type conversions.
Answer
Sign in to view the complete answer paper.
What is a constructor? What is its requirement in programming? Explain with program.
Answer
Sign in to view the complete answer paper.
What are the benefits of inheritance? Explain the various forms of inheritance with suitable code segments.
Answer
Sign in to view the complete answer paper.
How to define a package? How to access, import a package? Explain with examples.
Answer
Sign in to view the complete answer paper.
Explain method overriding with a suitable example program.
Answer
Sign in to view the complete answer paper.
With a program, illustrate user defined exception handling.
Answer
Sign in to view the complete answer paper.
How to handle multiple catch blocks for a nested try block? Explain with an example.
Answer
Sign in to view the complete answer paper.
Describe the need of thread synchronization. How is it achieved in Java programming? Explain with a suitable program.
Answer
Sign in to view the complete answer paper.
Write a JDBC program to search for an attribute in a table and display the entire tuple to the user. For example, display all the details of the student given his/her roll number.
Answer
Sign in to view the complete answer paper.
What is the role of event listeners in event handling? List the Java event listeners.
Answer
Sign in to view the complete answer paper.
Design a user interface to collect data from the student for admission application using swing components.
Answer
Sign in to view the complete answer paper.