JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD B.Tech III OBJECT ORIENTED PROGRAMMING THROUGH JAVA Previous Question Paper (August - 2022 - R18)
Answer any five questions
All questions carry equal marks
Main
What is the need of object oriented paradigm?
Answer
The object-oriented paradigm was developed to overcome the limitations of procedural programming, specifically regarding code complexity, maintenance, and scalability. As software systems grew in size, procedural approaches led to "spaghetti code" where data and functions were loosely coupled, making debugging and modification difficult.
Key reasons for the need for the object-oriented paradigm include:
- Encapsulation: It binds data and the methods that operate on that data into a single unit (class), protecting the internal state from unauthorized access.
- Reusability: Through inheritance, existing code can be extended or reused in new classes, reducing redundancy and development time.
- Maintainability: Modular design allows developers to update or fix specific components without affecting the entire system.
- Abstraction: It allows developers to hide complex implementation details and expose only the necessary functionality, simplifying the interaction with objects.
- Polymorphism: It provides the ability for objects to take on multiple forms, allowing a single interface to represent different underlying types, which enhances flexibility in system design.
Write a program to demonstrate constructor overloading in Java.
Answer
Constructor overloading in Java allows a class to have multiple constructors with different parameter lists. The compiler distinguishes between them based on the number and type of arguments passed during object creation.
class Student {
String name;
int age;
// Constructor with no arguments
Student() {
name = "Unknown";
age = 0;
}
// Constructor with one argument
Student(String n) {
name = n;
}
// Constructor with two arguments
Student(String n, int a) {
name = n;
age = a;
}
void display() {
System.out.println("Name: " + name + ", Age: " + age);
}
}
public class ConstructorDemo {
public static void main(String[] args) {
Student s1 = new Student();
Student s2 = new Student("Alice");
Student s3 = new Student("Bob", 20);
s1.display();
s2.display();
s3.display();
}
}What is byte code? How does it differ from source code, object code?
Answer
Sign in to view the complete answer paper.
Illustrate the use of ‘this’ keyword.
Answer
Sign in to view the complete answer paper.
List the frequently used methods of String class.
Answer
Sign in to view the complete answer paper.
What is inheritance? Discuss the benefits and costs of inheritance.
Answer
Sign in to view the complete answer paper.
Write a program to implement multi-level inheritance.
Answer
Sign in to view the complete answer paper.
Demonstrate dynamic method dispatch concept in Java.
Answer
Sign in to view the complete answer paper.
Compare BufferedInput stream with DataInput stream.
Answer
Sign in to view the complete answer paper.
How to define an interface? Give an example.
Answer
Sign in to view the complete answer paper.
What are the five keywords used in Java exception handling? With suitable code snippets explain their usage.
Answer
Sign in to view the complete answer paper.
Write a program to read date of birth from user and display the age of the user.
Answer
Sign in to view the complete answer paper.
How to create threads in Java? Illustrate with an example.
Answer
Sign in to view the complete answer paper.
Write a program to solve producer-consumer problem using threads.
Answer
Sign in to view the complete answer paper.
Describe delegation event model.
Answer
Sign in to view the complete answer paper.
What is a layout manager? Discuss different types of layout manager.
Answer
Sign in to view the complete answer paper.
Write code to create an Applet drawing a smiley face using graphics class.
Answer
Sign in to view the complete answer paper.
Explain model-view-controller architecture for application development.
Answer
Sign in to view the complete answer paper.