Frequently Asking Question
In this Java Interview Questions blog, we have compiled some of the most essential Java Programming Interview Questions and Answers which helps you stand a chance in the interview process.
Get Java Training from experts. Call us @ +91 86087 00340 for a free demo session!
Java Interview Question and Answers
- Explain about Object oriented programming Language.
- Does Constructor Return any value?
- Can we overload main() method?
- What is marker interface?
- Can an Interface be final?
- What is Exception Handling?
- What are the two types of Exceptions in Java ?
- What is multithreading?
- What are the basic interfaces of Java Collections Framework
- What are the JDBC API components?
- What are the steps to connect to the database in java?
- What are the JDBC Statements?
- Super class of Java
- Does Java support Multiple Inheritance?
- Why String is Immutable Object?
- Nested Forloops
- Basic inheritance program
- What is gc?
- What is the Difference Between HashSet and TreeSet
- What is the Difference Between Collection and Collections?
- What is the life-cycle of a Servlet?
- What is JSP?
- What is over loading and over riding ?
- What is Abstraction and Encapsulation ?
- What is array?
- How to reverse string without using reverse Method?
- Features of java?
- Write a query how delete rows from mysql.
- Difference between truncate,delete,drop.
- What are the jdbc drivers.
- What is Dynmic binding.
- Difference between string and string buffer.
- What is class and object?
- What are the access modifer in java?
- Difference between local and global variable.
- What are the two types of Java programs?
- What are the features of Java?
- What are the 4 types of JDBC drivers?
- What is a Java driver?
- What are the steps required to run a query in JDBC?
- What is JDBC Addbatch?
- Which interface provides methods for batch processing in JDBC?
- What is the connection interface in JDBC?
- What is the difference between a Java application and a Java applet?
Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance.
when you call the constructor using a new keyword you get an object. Though it doesn’t explicitly return something but instead it creates or constructs something which you can use as an instance of a class. yes, it is the current class instance. (We cannot use return type yet it returns a value).
yes we can overload main method. main method must not be static main method. Yes, main method can be overloaded.
A marker interface in Java is an interface with no fields or methods. Put more simply, an empty interface in Java is called a marker interface. Examples: Serializable , Cloneable and Remote interfaces.
An interface is a pure abstract class. Hence, all methods in an interface are abtract, and must be implemented in the child classes. So, by extension, none of them can be declared as final
An unexpected event that disturbs the normal flow of program.
- checked Exception
- Unchecked Exception
Multithreading in java is a process of executing multiple threads simultaneously. A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking.
Java Collection means a single unit of objects. Java Collection framework provides many interfaces (Set, List, Queue, Deque) and classes (Array List, Vector, Linked List, Priority Queue, HashSet, Linked HashSet, TreeSet).
The JDBC API. The JDBC API gives access of programming data from the Java. JDBC Driver Manager. The JDBC Driver Manager is the class in JDBC API. JDBC Test Suite. JDBC-ODBC Bridge.
- Step 1: Register the Driver class
- Step 2: Create connection
- Step 3: Create statement
- Step 4: Execute queries
- Step 5: Close connection
It can be used for general-purpose access to the database. It is useful when you are using static SQL statements at Run time.
It can be used when you plan to use the same SQL statement many times. The Prepared Statement interface accepts input parameters at Run time.
Callable Statement can be used when you want to access database stored procedures.
The super keyword in Java is a reference variable which is used to refer immediate parent class object.
No..Java Does not Support Multiple in hesitance. Once string object is created its data or state can’t be changed but a new string object is created.
In Java, string objects are immutable. Immutable simply means unmodifiable or unchangeable.
public static void main(String  args)
public void add()
class B extends A
public static void main(String  args)
A ob=new A();
UN Reachable objects in program automatically eligible for garbage collection.
TreeSet : tree set is faster performance compare to hashset.
HashSet : hash set not maintain insertion order.but tree set maintain ascending order of elements.
Collection is a interface and Collections is a class. both are contains in util package.
Java server page used for front end development. method overloading programm and methos overriding and differences
Overloading: same method but differnt parameters.
Overriding: same method name in different class.
Abstraction:hiding internal implementation.
Encapsulation:wrapping of data in single unit.
Collection of homogenous datatypes.
- platform indepdent
- object oriented
- high performance
delete from table(name) where (row)=;
Truncate: total rows from table
Drop: to delete the table from database
Delete: particular row from table
- JDBC-ODBC Bridge.
- Native api
- Network protocol
- Thin driver
From the reference of base class we can create object to derived class
String is an immutable object
String buffer is an mutable Object
Class is blue print of program
object is an reference of class
Local Variable Declared in side method
Global Variable Declared inside class out side method
There are many types of Java programs that run differently: Java Applet: small program written in Java that is downloaded from a website and run inside a Web browser on a client computer Application: run on a client computer.
Here are the main features of Java: * Simple: Java language is easy to learn. … * Familiar: Java is similar to C / C ++, but it eliminates the disadvantages and complexities of C / C ++ as pointers and several inheritances. … * Object-oriented: … * Robust: … * Of course: … * High performance: … * Multiprocess: … * Platform independence.
There are 4 types of JDBC drivers: JDBC-ODBC bridge driver Native API driver (partially java driver) Network protocol driver (fully java driver) Driver Slim (fully java driver)
A “driver class” is usually just the class that contains a main. In a real project, you can often have multiple “Driver Classes” for testing and other things, or you can create a main on any of your objects and select the executable class through your IDE or simply by specifying “java classname” .
The key steps involved in the process of connecting to a database and running a query are as follows: Import JDBC packages. Load and register the JDBC driver. Open a connection Create a declaration object to execute a query, run the declaration object, and return a query result set.
JDBC – Batch Processing. … The method will return true if your JDBC driver supports this function. The addBatch () method of Statement, PreparedStatement, and CallableStatement is used to add individual statements to the batch. The executeBatch () is used to start executing all grouped declarations.
Batch processing in JDBC. Instead of executing a single query, we can execute a batch (group) of queries. This makes the performance fast. The java.sql.Statement and java.sql.PreparedStatement interfaces provide methods for batch processing.
Connection interface. A Connection is the session between java application and database. The Connection interface is a factory of Statement, PreparedStatement, and DatabaseMetaData i.e. object of Connection can be used to get the object of Statement and DatabaseMetaData.
What is the difference between applets and an application. … An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included. An application is a standalone Java program that runs as a true application, outside of a browser.