JNTU
JNTU MCA 2022 JAVA PROGRAMMING Previous Question Paper (September/October - 2022 - R15)
Answer any five questions. All questions carry equal marks.
Main
What is autoboxing and autounboxing? Give examples.
Answer
Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes (e.g., converting an int to an Integer). This occurs when a primitive value is passed as a parameter to a method that expects an object or assigned to a variable of the wrapper class type.
Autounboxing is the reverse process, where the Java compiler automatically converts an object of a wrapper type back into its corresponding primitive type (e.g., converting an Integer back to an int). This occurs when an object is assigned to a primitive variable or used in an expression requiring a primitive.
Integer obj = 10; // Compiler treats this as Integer.valueOf(10)
// Autounboxing example
int val = obj; // Compiler treats this as obj.intValue()
Discuss about garbage collection.
Answer
Garbage collection is the process by which the Java Virtual Machine (JVM) automatically manages memory by reclaiming memory occupied by objects that are no longer reachable by the application. This mechanism eliminates the need for manual memory deallocation, thereby reducing memory leaks and dangling pointer errors.
- Eligibility: An object becomes eligible for garbage collection when it is no longer reachable from any live thread or static reference.
- Process: The Garbage Collector (GC) runs as a daemon thread in the background. It identifies unreachable objects and marks them for deletion.
- Triggering: While the JVM decides when to run the GC, a programmer can suggest it by calling
System.gc(), though this does not guarantee immediate execution. - Finalization: Before reclaiming memory, the GC calls the
finalize()method of the object, providing a final opportunity for the object to perform cleanup tasks.
Explain break and continue statements with examples.
Answer
Sign in to view the complete answer paper.
Discuss about overloading methods.
Answer
Sign in to view the complete answer paper.
What is inner class? What are local, static and anonymous inner classes?
Answer
Sign in to view the complete answer paper.
What is a package? How are they imported? What are its advantages?
Answer
Sign in to view the complete answer paper.
Discuss about preventing inheritance.
Answer
Sign in to view the complete answer paper.
Explain Set and List collection interfaces.
Answer
Sign in to view the complete answer paper.
Explain Iterator interface and ListIterator interface.
Answer
Sign in to view the complete answer paper.
What is a thread? How does it differ from a process? What are thread priorities? How do you set thread priorities?
Answer
Sign in to view the complete answer paper.
Explain JTextField and JTextArea in detail.
Answer
Sign in to view the complete answer paper.