UNIT-I: Core Java + Networking + Applet
Q: What is Java? List its features.
A: Java is a high-level, object-oriented programming language developed by Sun Microsystems.
Features: Platform Independent, Object-Oriented, Secure, Robust, Multithreaded, Portable.
Q: Difference between JDK, JRE, and JVM?
A: JDK: Includes tools to develop Java programs.
JRE: Environment to run Java programs.
JVM: Converts bytecode into machine code at runtime.
Q: What is platform independence in Java?
A: Java code is compiled into bytecode which can be executed on any system with JVM.
Q: What is bytecode?
A: Bytecode is an intermediate code generated by the Java compiler, executed by the JVM.
Q: What is inheritance in Java? Types of inheritance?
A: Inheritance allows one class to acquire properties and methods of another class.
Types: Single, Multilevel, Hierarchical.
Q: Difference between method overloading and overriding?
A: Overloading: Same method name, different parameters.
Overriding: Redefining a method in subclass with same signature.
Q: Can we override a static method?
A: No, static methods are not overridden. They are hidden.
Q: What is exception handling in Java?
A: Mechanism to handle runtime errors using try, catch, throw, throws, and finally.
Q: Difference between checked and unchecked exceptions?
A: Checked: Compile-time (e.g., IOException).
Unchecked: Runtime (e.g., NullPointerException).
Q: Explain try-catch-finally with an example.
A: try {
int a = 5/0;
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero");
} finally {
System.out.println("Finally block executed");
Q: What is the use of throw and throws?
A: throw: Explicitly throw an exception.
throws: Declares exceptions that a method might throw.
Q: What is a thread in Java?
A: A thread is a lightweight subprocess, a smallest unit of CPU execution.
Q: Difference between Thread class and Runnable interface?
A: Thread: Extend class, override run().
Runnable: Implement interface, pass to Thread object.
Q: What is synchronization and why is it needed?
A: Prevents multiple threads from accessing critical sections simultaneously.
Q: What is the use of join(), sleep(), yield()?
A: join(): Waits for a thread to finish.
sleep(): Pauses thread for some time.
yield(): Allows other threads of equal priority to run.
Q: What is an Applet?
A: A Java program that runs in a web browser.
Q: Difference between Applet and Application?
A: Application: Runs independently with main().
Applet: Runs inside a browser.
Q: Applet Lifecycle Methods?
A: init(), start(), stop(), destroy()
Q: How to embed an Applet in HTML?
A: <applet code="MyApplet.class" width="300" height="300"></applet>
Q: What is a socket?
A: A socket is an endpoint for communication between two machines.
Q: Difference between TCP and UDP?
A: TCP: Connection-oriented, reliable.
UDP: Connectionless, faster.
Q: How do you connect to a server in Java?
A: Using Socket class for clients and ServerSocket for server.
Q: What are ServerSocket and Socket classes?
A: ServerSocket: Waits for client requests.
Socket: Used by clients to connect.
UNIT-II: JavaBeans and Servlets
Q: What is a JavaBean?
A: A Java class that follows certain conventions and encapsulates objects.
Q: How do you create a JavaBean?
A: Must have no-arg constructor, be serializable, and have getter/setter methods.
Q: What are JavaBean properties?
A: Attributes accessed using getter and setter methods.
Q: Types of Beans?
A: Stateful Session Bean, Stateless Session Bean, Entity Bean.
Q: What is a Servlet?
A: A Java program that runs on a server and handles client requests.
Q: Explain Servlet Lifecycle.
A: init(): Initializes the servlet.
service(): Handles requests.
destroy(): Releases resources.
Q: Difference between GET and POST?
A: GET: Appends data in URL.
POST: Sends data in request body.
Q: How is session tracking done in Servlets?
A: Via Cookies, URL rewriting, Hidden fields, HttpSession.
Q: What are Cookies in Servlets?
A: Small data stored on client side to maintain session.
UNIT-III: JSP (Java Server Pages)
Q: What is JSP?
A: Java Server Pages used to create dynamic web pages.
Q: Difference between JSP and Servlet?
A: JSP: Presentation layer.
Servlet: More control over logic.
Q: What are JSP Implicit Objects?
A: Predefined objects like request, response, out, session, etc.
Q: What is JSP Scripting?
A: Allows Java code inside HTML using <% %>, <%= %>, <%! %>
Q: What are JSP Directives?
A: Instructions to JSP container: page, include, taglib.
Q: What are JSP Standard Actions?
A: Tags like <jsp:useBean>, <jsp:setProperty>, etc.
Q: What are Custom Tag Libraries?
A: User-defined tags for reusable functionality (e.g., JSTL).
UNIT-IV: RMI and Hibernate
Q: What is RMI in Java?
A: Allows method invocation across JVMs.
Q: Roles of Client and Server in RMI?
A: Server publishes remote objects. Client looks up and invokes them.
Q: Steps to Set Up RMI?
A: Define interface, implement, start RMI registry, register, lookup.
Q: What is the role of rmic?
A: Generates stub and skeleton (older versions).
Q: How are parameters passed in remote methods?
A: Passed by value, must be serializable.
Q: What is Hibernate?
A: ORM framework mapping Java classes to DB tables.
Q: Advantages of Hibernate?
A: No JDBC code, HQL, caching, lazy loading.
Q: Explain Hibernate Architecture.
A: Configuration, SessionFactory, Session, Transaction, Query.
Q: What is HQL?
A: Hibernate Query Language - object-oriented SQL.
Q: Difference between get() and load()?
A: get(): returns null if not found.
load(): throws exception if not found.