Browsed by
Tag: java 8 interview questions and answers

What an I/O Filter

What an I/O Filter

An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another. In the context of Core Java, an I/O filter typically refers to an object that is used to perform filtering on data as it is read from or written to a stream. Input/Output (I/O) streams in Java are used for reading from or writing to various sources, such as…

Read More Read More

What Classes of Exceptions May be Thrown by a Throw Statement

What Classes of Exceptions May be Thrown by a Throw Statement

A throw statement may throw any expression that may be assigned to the Throwable type. In Java, the throw statement is used to explicitly throw an exception. When you use the throw statement, you typically throw an instance of a class that extends either Throwable, which is the base class for all exceptions and errors, or one of its subclasses. The two main subclasses of Throwable are: Exception: This is the class most commonly used for exceptional conditions that a program should…

Read More Read More

To What Value is a Variable of the Boolean Type Automatically Initialized

To What Value is a Variable of the Boolean Type Automatically Initialized

The default value of the boolean type is false. In Java, local variables (including boolean variables) are not automatically initialized. If you declare a boolean variable within a method or block without initializing it, the compiler will generate an error if you try to use the variable before giving it a value. For example: java public class Example { public static void main(String[] args) { boolean myBoolean; // Compiler error: variable myBoolean might not have been initialized System.out.println(myBoolean); } } In the above…

Read More Read More

Can Abstract Class Be Instantiated

Can Abstract Class Be Instantiated

No abstract class cannot be instantiated i.e you cannot create a new object of this class No, an abstract class cannot be instantiated in Java. An abstract class is a class that is declared with the abstract keyword. It may have abstract methods (methods without a body) that must be implemented by its subclasses. Abstract classes cannot be instantiated on their own because they may contain incomplete or abstract methods, and it doesn’t make sense to create objects of an…

Read More Read More

What Are The Types of Statements in JDBC

What Are The Types of Statements in JDBC

the JDBC API has 3 Interfaces, (1. Statement, 2. PreparedStatement, 3. CallableStatement ). The key features of these are as follows: Statement This interface is used for executing a static SQL statement and returning the results it produces. The object of Statement class can be created using Connection.createStatement() method. PreparedStatement A SQL statement is pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times. The object of PreparedStatement class can be…

Read More Read More

How to do Database Connection Using JDBC thin Driver

How to do Database Connection Using JDBC thin Driver

This is one of the most commonly asked questions from JDBC fundamentals, and knowing all the steps of JDBC connection is important. import java.sql.*; class JDBCTest { public static void main (String args []) throws Exception { //Load driver class Class.forName (“oracle.jdbc.driver.OracleDriver”); //Create connection Connection conn = DriverManager.getConnection (“jdbc:oracle:thin:@hostname:1526:testdb”, “scott”, “tiger”); // @machineName:port:SID,   userid,  password   Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(“select ‘Hi’ from dual”); while (rs.next()) System.out.println (rs.getString(1));   // Print col 1 => Hi stmt.close(); } } To establish a database connection using JDBC thin driver in Core Java, you typically follow these steps: Load the JDBC driver: Use Class.forName() to dynamically load the JDBC driver for your database. For a thin driver, this is usually provided…

Read More Read More

Is JSP Technology Extensible

Is JSP Technology Extensible

YES. JSP technology is extensible through the development of custom actions, or tags, which are encapsulated in tag libraries. Yes, JavaServer Pages (JSP) technology is extensible. JSP allows developers to create custom tags, known as JSP custom tags or simply custom tags, to encapsulate reusable functionality. This extensibility enables developers to extend the standard JSP functionality and create modular and maintainable web applications. Custom tags in JSP provide a way to separate the logic of a web application into reusable…

Read More Read More