Jawaharlal Nehru Technological University Hyderabad

Jawaharlal Nehru Technological University Hyderabad B.Tech II Year OBJECT ORIENTED PROGRAMMING THROUGH JAVA Previous Question Paper (September - 2021 - R16)

B.Tech | II Year | I Semester | R16 | September - 2021

Answer PaperPaper Code: 133BMMaximum Marks: 75Time: 3 hours

Answer any five questions. All questions carry equal marks.

Main

1

Write a program to implement multilevel hierarchy, use super keyword to define methods in sub classes.

15 marks

Answer

Multilevel inheritance in Java is a process where a class is derived from a class which is also derived from another class, i.e., a class has more than one parent class. The super keyword is a reference variable used to refer to the immediate parent class object, allowing subclasses to invoke overridden methods or access hidden members of the superclass.

The following program demonstrates a three-level hierarchy: Grandparent → Parent → Child.

class Grandparent {
    void display() {
        System.out.println("Grandparent class method");
    }
}

class Parent extends Grandparent {
    void display() {
        super.display(); // Invoking Grandparent method
        System.out.println("Parent class method");
    }
}

class Child extends Parent {
    void display() {
        super.display(); // Invoking Parent method
        System.out.println("Child class method");
    }
}

public class MultilevelDemo {
    public static void main(String[] args) {
        Child obj = new Child();
        obj.display();
    }
}

Key Concepts:

  • Inheritance Hierarchy: The Child class inherits properties from Parent, which in turn inherits from Grandparent.
  • Method Overriding: Each class provides a specific implementation of the display() method.
  • Super Keyword: Used within the display() method of the subclass to explicitly call the overridden method of the immediate superclass, ensuring that the entire chain of execution is maintained.
  • Execution Flow: When obj.display() is called, the Child class invokes super.display(), which triggers the Parent class method, which then triggers the Grandparent class method, resulting in a sequential output of all three levels.
215 marks
a

How is abstraction different from information hiding?

8 marks

Answer

  • Abstraction is a design-level technique that focuses on the essential characteristics of an object, ignoring irrelevant details. It provides a simplified view of a system by defining a clear interface, allowing the user to interact with the object without needing to understand its internal implementation.
  • Information Hiding is an implementation-level strategy that restricts access to the internal state and data of an object. It ensures that the internal representation of an object is protected from unauthorized or accidental modification by external entities.
  • Key Differences:
    • Abstraction is about what an object does (the interface), whereas information hiding is about how it achieves its functionality (the implementation).
    • Abstraction reduces complexity by providing a high-level model; information hiding increases security and maintainability by enforcing encapsulation.
    • Abstraction is often achieved through abstract classes and interfaces, while information hiding is primarily achieved using access modifiers (private, protected).
b

What features of Java make it a robust language?

7 marks

Answer

Sign in to view the complete answer paper.

3

Write a program to merge the content of two files (user’s contacts in a mobile) into a target file.

15 marks

Answer

Sign in to view the complete answer paper.

415 marks
a

Discuss access protection for packages.

7 marks

Answer

Sign in to view the complete answer paper.

b

How to inherit an interface to another?

8 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

Describe the life cycle of a thread.

7 marks

Answer

Sign in to view the complete answer paper.

b

How to assign priorities to threads in Java program?

8 marks

Answer

Sign in to view the complete answer paper.

6

What is an exception? How is it different from an error? What are the basic keywords used to handle exceptions in Java? Explain their usage.

15 marks

Answer

Sign in to view the complete answer paper.

715 marks
a

How to obtain an array from an ArrayList?

7 marks

Answer

Sign in to view the complete answer paper.

b

What steps need to be followed to use an iterator to cycle through the contents of a collection?

8 marks

Answer

Sign in to view the complete answer paper.

8

Create a user interface using MVC architecture and swing concepts to book a seat in a bus [like redbus/abhibus applications].

15 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the solved question paper with answers of OBJECT ORIENTED PROGRAMMING THROUGH JAVA from Jawaharlal Nehru Technological University Hyderabad for B.Tech IT II Year I Semester, September - 2021, R16.

For the question paper without answers, switch to the Question Paper tab.

Other papers in OBJECT ORIENTED PROGRAMMING THROUGH JAVA

Loading Question Papers

Fetching data from database...