JNTU
JNTU B.Tech III OBJECT ORIENTED PROGRAMMING THROUGH JAVA Previous Question Paper (November/December - 2020 - R15)
Answer any five questions. All questions carry equal marks.
Main
Discuss the overloading and overriding concepts in OOP.
Answer
Method Overloading occurs when multiple methods in the same class share the same name but have different parameter lists (different number, type, or order of arguments). It is a form of compile-time polymorphism, as the compiler determines which method to invoke based on the method signature at compile time. It improves code readability and allows methods to perform similar tasks with different input types.
Method Overriding occurs when a subclass provides a specific implementation for a method that is already defined in its superclass. The method signature must be identical. It is a form of run-time polymorphism (dynamic method dispatch), where the JVM determines which method to execute based on the actual object type at runtime. It is a fundamental aspect of inheritance, allowing for specialized behavior in subclasses.
Write about garbage collection and the finalize method in Java.
Answer
Garbage Collection is the automatic process by which the Java Virtual Machine (JVM) manages memory by reclaiming memory occupied by objects that are no longer reachable by the application. This eliminates the need for manual memory deallocation, reducing memory leaks and dangling pointer issues. The garbage collector identifies unreachable objects—those that no longer have any active references—and marks them for deletion.
The finalize() method is a protected method defined in the Object class that the garbage collector calls on an object before reclaiming its memory. It is intended for performing cleanup tasks, such as closing file handles or releasing native resources. However, relying on finalize() is discouraged because it is not guaranteed to be called promptly, and its execution timing is non-deterministic. Modern Java development prefers using try-with-resources blocks or the AutoCloseable interface for resource management instead.
What do you mean by inheritance? Explain how inheritance can be achieved in Java. Give examples.
Answer
Sign in to view the complete answer paper.
How does java’s multithreading capability enable you to write more efficient programs? Explain.
Answer
Sign in to view the complete answer paper.
List and explain the benefits of Exception Handling.
Answer
Sign in to view the complete answer paper.
Define Event. Explain about Adapter classes with example.
Answer
Sign in to view the complete answer paper.
Write a program to create a form for login page using swing components.
Answer
Sign in to view the complete answer paper.
How would you detect a key press in a JComboBox? Explain.
Answer
Sign in to view the complete answer paper.
Define scope and lifetime of variables. Explain about the scope and lifetime of variables in Java.
Answer
Sign in to view the complete answer paper.
Differentiate between the prefix and postfix forms of the increment operator. Give examples for each.
Answer
Sign in to view the complete answer paper.
How to create a package in java? Give example code.
Answer
Sign in to view the complete answer paper.
Write a java program to illustrate abstract classes.
Answer
Sign in to view the complete answer paper.
Explain the effect of adding synchronized keyword to a method.
Answer
Sign in to view the complete answer paper.
Explain thread priorities.
Answer
Sign in to view the complete answer paper.