Java Interview Questions: 2
39 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

How can a GUI component handle its own events?

By implementing the corresponding event-listener interface and adding itself as its own event listener

What advantage do Java’s layout managers provide over traditional windowing systems?

They are able to accommodate platform-specific differences among windowing systems

What is the design pattern used by Java for all Swing components?

The Model View Controller (MVC) pattern

What is JDBC?

<p>An abstraction layer that allows users to choose between databases</p> Signup and view all the answers

What is the role of Driver in JDBC?

<p>To provide vendor-specific implementations of the abstract classes provided by the JDBC API</p> Signup and view all the answers

What is the purpose of the Class.forName method?

<p>To load the driver that will establish a connection to the database</p> Signup and view all the answers

What is the advantage of PreparedStatement over Statement?

<p>PreparedStatements are precompiled and thus, their performance is much better</p> Signup and view all the answers

What is the use of CallableStatement?

<p>Not provided in the text</p> Signup and view all the answers

What is the permanent generation space in the Java heap?

<p>The permanent generation space in the Java heap is where the JVM stores metadata, such as class definitions and method bytecode.</p> Signup and view all the answers

What is the difference between the Serial and Throughput Garbage Collectors?

<p>The Serial Garbage Collector pauses the JVM for garbage collection, while the Throughput Garbage Collector uses multiple threads to concurrently garbage collect.</p> Signup and view all the answers

When does an Object become eligible for Garbage Collection in Java?

<p>An Object becomes eligible for Garbage Collection in Java when it is no longer referenced by any part of the program.</p> Signup and view all the answers

What is the difference between an Exception and an Error in Java?

<p>An Exception is a condition that occurs at runtime, whereas an Error is a serious problem that arises during program execution.</p> Signup and view all the answers

What is the importance of the finally block in exception handling?

<p>The finally block is used to perform cleanup operations, regardless of whether an exception is thrown or caught.</p> Signup and view all the answers

What is an Applet in Java?

<p>An Applet is a small Java program that runs in a web browser.</p> Signup and view all the answers

What is the difference between a Choice and a List in Swing?

<p>A Choice is a single-selection dropdown list, while a List is a multiple-selection list.</p> Signup and view all the answers

What is the role of a Driver in JDBC?

<p>A Driver is a class that implements the JDBC API, providing a connection to a database.</p> Signup and view all the answers

What is the method used to prepare a CallableStatement?

<p>prepareCall()</p> Signup and view all the answers

What is the purpose of connection pooling in Java?

<p>To reduce the cost of opening and closing database connections, especially when the number of database clients increases.</p> Signup and view all the answers

What is the main feature of Remote Method Invocation (RMI) in Java?

<p>Location transparency, allowing remote method invocation to be treated as a local method invocation.</p> Signup and view all the answers

What is the benefit of using stored procedures in a database?

<p>Security and modularity.</p> Signup and view all the answers

What is the role of a pool in connection pooling?

<p>To maintain a pool of database connections that can be reused to serve future requests.</p> Signup and view all the answers

What is the purpose of a CallableStatement in JDBC?

<p>To execute stored procedures in a database.</p> Signup and view all the answers

What is the advantage of using RMI in Java?

<p>Location transparency, allowing remote method invocation to be treated as a local method invocation.</p> Signup and view all the answers

What is the cost of not using connection pooling in Java?

<p>High resource consumption, especially when the number of database clients increases.</p> Signup and view all the answers

What is the purpose of Connection pooling in JDBC?

<p>To improve performance by reusing existing connections</p> Signup and view all the answers

What is the basic principle of RMI architecture?

<p>Distributed objects</p> Signup and view all the answers

What is the role of the Remote Interface in RMI?

<p>To define the methods that can be invoked remotely</p> Signup and view all the answers

What is the difference between bind() and rebind() methods of Naming Class?

<p>bind() binds a new name, rebind() replaces an existing binding</p> Signup and view all the answers

What is the role of the stub in RMI?

<p>Acts as a proxy for the remote object</p> Signup and view all the answers

What is DGC in RMI?

<p>Distributed Garbage Collection</p> Signup and view all the answers

What is the purpose of a CallableStatement in JDBC?

<p>To execute stored procedures</p> Signup and view all the answers

What is the benefit of using a Connection pool in JDBC?

<p>Improves performance by reusing existing connections</p> Signup and view all the answers

What is the main difference between HTTP session and cookie in terms of data storage?

<p>HTTP session is capable of storing any Java object, while a cookie can only store String objects.</p> Signup and view all the answers

What is HTTP Tunneling and how does it work?

<p>HTTP Tunneling is a technique by which, communications performed using various network protocols are encapsulated using the HTTP or HTTPS protocols.</p> Signup and view all the answers

What is the difference between sendRedirect and forward methods in terms of request scope objects?

<p>The previous request scope objects are not available after a redirect, but are available after forwarding.</p> Signup and view all the answers

What is the purpose of URL encoding and URL decoding in a URL?

<p>URL encoding replaces spaces and special characters with their corresponding Hex representation, and URL decoding is the opposite procedure.</p> Signup and view all the answers

What is a JSP page and how does it mix content?

<p>A Java Server Page (JSP) mixes static data with dynamically-generated content.</p> Signup and view all the answers

How are JSP requests handled in a web server?

<p>On the arrival of a JSP request, the browser first requests a page with a .jsp extension.</p> Signup and view all the answers

What is the difference between HTTP and HTTPS protocols?

<p>HTTPS is a secured version of HTTP, providing encryption and authentication.</p> Signup and view all the answers

Study Notes

GUI Components

  • A GUI component can handle its own events by implementing the corresponding event-listener interface and adding itself as its own event listener.
  • An event adapter provides a default implementation of an event-listener interface.

JDBC

  • JDBC is an abstraction layer that allows users to choose between databases.
  • JDBC enables developers to write database applications in Java without having to concern themselves with the underlying details of a particular database.
  • The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API.
  • The Class.forName method is used to load the driver that will establish a connection to the database.
  • PreparedStatements are precompiled, and thus, their performance is much better than Statements.
  • PreparedStatements can be reused with different input values to their queries.
  • CallableStatement is used to execute stored procedures.

Layout Managers

  • Java's layout managers provide a consistent manner of laying out components across all windowing platforms.
  • Layout managers are not tied to absolute sizing and positioning, which allows them to accommodate platform-specific differences among windowing systems.

Java Applets

  • An applet is a Java program that runs on a web browser.
  • The life cycle of an applet includes loading, initializing, starting, and stopping.
  • Applets are restricted from accessing certain system resources due to security reasons.

Remote Method Invocation (RMI)

  • RMI is a Java API that performs the object-oriented equivalent of remote procedure calls (RPC).
  • RMI offers location transparency, which means a user feels that a method is executed on a locally running object.
  • RMI is the process of activating a method on a remotely running object.

JDBC Connection Pooling

  • Connection pooling is a technique that allows multiple clients to share a pool of database connections.
  • The interaction with a database can be costly, regarding the opening and closing of database connections.
  • Connection pooling reduces the cost of opening and closing database connections by maintaining a pool of connections.

JSP

  • A JSP page is a text document that contains static data and JSP elements.
  • JSP is a technology that mixes static content with dynamically-generated content.
  • JSP requests are handled by the browser, which first requests a page with a .jsp extension.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

Java-Interview-Questions.pdf

More Like This

Use Quizgecko on...
Browser
Browser