quiz image

Java Interview Questions: 2

TopCoding avatar
TopCoding
·
·
Download

Start Quiz

Study Flashcards

39 Questions

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?

An abstraction layer that allows users to choose between databases

What is the role of Driver in JDBC?

To provide vendor-specific implementations of the abstract classes provided by the JDBC API

What is the purpose of the Class.forName method?

To load the driver that will establish a connection to the database

What is the advantage of PreparedStatement over Statement?

PreparedStatements are precompiled and thus, their performance is much better

What is the use of CallableStatement?

Not provided in the text

What is the permanent generation space in the Java heap?

The permanent generation space in the Java heap is where the JVM stores metadata, such as class definitions and method bytecode.

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

The Serial Garbage Collector pauses the JVM for garbage collection, while the Throughput Garbage Collector uses multiple threads to concurrently garbage collect.

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

An Object becomes eligible for Garbage Collection in Java when it is no longer referenced by any part of the program.

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

An Exception is a condition that occurs at runtime, whereas an Error is a serious problem that arises during program execution.

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

The finally block is used to perform cleanup operations, regardless of whether an exception is thrown or caught.

What is an Applet in Java?

An Applet is a small Java program that runs in a web browser.

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

A Choice is a single-selection dropdown list, while a List is a multiple-selection list.

What is the role of a Driver in JDBC?

A Driver is a class that implements the JDBC API, providing a connection to a database.

What is the method used to prepare a CallableStatement?

prepareCall()

What is the purpose of connection pooling in Java?

To reduce the cost of opening and closing database connections, especially when the number of database clients increases.

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

Location transparency, allowing remote method invocation to be treated as a local method invocation.

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

Security and modularity.

What is the role of a pool in connection pooling?

To maintain a pool of database connections that can be reused to serve future requests.

What is the purpose of a CallableStatement in JDBC?

To execute stored procedures in a database.

What is the advantage of using RMI in Java?

Location transparency, allowing remote method invocation to be treated as a local method invocation.

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

High resource consumption, especially when the number of database clients increases.

What is the purpose of Connection pooling in JDBC?

To improve performance by reusing existing connections

What is the basic principle of RMI architecture?

Distributed objects

What is the role of the Remote Interface in RMI?

To define the methods that can be invoked remotely

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

bind() binds a new name, rebind() replaces an existing binding

What is the role of the stub in RMI?

Acts as a proxy for the remote object

What is DGC in RMI?

Distributed Garbage Collection

What is the purpose of a CallableStatement in JDBC?

To execute stored procedures

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

Improves performance by reusing existing connections

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

HTTP session is capable of storing any Java object, while a cookie can only store String objects.

What is HTTP Tunneling and how does it work?

HTTP Tunneling is a technique by which, communications performed using various network protocols are encapsulated using the HTTP or HTTPS protocols.

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

The previous request scope objects are not available after a redirect, but are available after forwarding.

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

URL encoding replaces spaces and special characters with their corresponding Hex representation, and URL decoding is the opposite procedure.

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

A Java Server Page (JSP) mixes static data with dynamically-generated content.

How are JSP requests handled in a web server?

On the arrival of a JSP request, the browser first requests a page with a .jsp extension.

What is the difference between HTTP and HTTPS protocols?

HTTPS is a secured version of HTTP, providing encryption and authentication.

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.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser