What is the difference between an interface and an abstract class?
Interface
Abstract
Both
What are abstract methods?
An abstract method is a method that is declared without an implementation.
What are default methods?
Default methods enable you to add new functionality to the interfaces by specifying the method definition and using the default keyword as the method signature
What is an interface class?
Interface is a reference type and is a contract that binds specific method signatures and fields to the class that implements it
What is an abstract class?
An abstract class is a class that is declared abstract. It may or may not include abstract methods.
What is the diamond problem?
There is a class A. Both class B and C derives from class A. Thus both class B and class C implements method from class A. Now we have class D. Class D derives from class B and C. The diamond problem comes from when class D makes a call to method definitions in class A. This call is ambiguous because it is not sure whether to call the version of the method derived from class B or class C.
Java does not have the diamond problem since it does not support multiple inheritance. Instead, Java uses interfaces.
What is the static keyword?
Variables that are declared static is called a class variable that is initialized one and all instances share the same copy of the variable. It can be accessed directly without creating an instance of the class. It can be accessed directly by the class name and doesn’t need any object.
What is an instance variable
A variable without the static keyword and each instance of the class has its own copy of the variable.
What is the difference between an ArrayList and a Vector?
Vector is synchronized, which means only one thread is working and no other thread can perform an operation at a time.
Arraylist is not synchronized, so multiple threads can work on ArrayList at the same time.
Both ArrayList and a Vector can grow and shrink dynamically, but the way they resize is different. Vector double itself by ArrayList grow by half of its size.
ArrayList is faster since it is non-synchronized and Vectors are slower because it is thread-safe since the Vector gets locked until the work is complete by the thread.
An ArrayList is fail-fast since it is not thread safe unlike a Vector
What is fail-fast?
Fail-fast is an exception that gets thrown when a collection is being iterated and it detects some changes being made to the collection.
What is the difference between a tree set and a hashset?
HashSet
Tree Set
Both
What is a hashcode?
A number generated from an object. It is used to store and retrieve objects quickly in a hashtable.
What type of Collections that does not allow duplicates?
Set
A set is a Collection that cannot contain duplicate elements.
What is the difference between HashTable and HashMap?
HashMap
HashTable
How do you serialize (persist) an object in Java?
Java has the Serialization API
Serialization is the process of saving an object’s state to a persistence store and also rebuilding the object from the save information when needed in the future.
To serialize an object
What is a stored procedure and how would you call it in Java?
A stored procedure is an executable block of code that is written in PL/SQL and stored in the Oracle database. A stored procedure is called from a Java class using CallableStatement object. When the procedure is called, its name and any relevant parameters are sent over the JDBC connection to the DBMS which executes the procedure and returns the result (if applicable) via the connection.
What is PL/SQL
PL/SQL is a procedural language extension to Structured Query Language. The purpose is to combine database language and procedural programming language. The basic unit in PL/SQL is called a block, which is part up of three parts: a declarative part, an executable part, and an exception-building part.
What are the difference between stored procedures and functions?
Stored Procedure
Function
What is JDBC?
JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming language and the database.
How do you establish a connection for JDBC?
DriverManager
.getConnection(“jdbc:mysql://localhost:3306/test”, “username”,”password”)
test is a database schema
What is JSP?
JavaServer Pages
It is a server-side programming technology that enables the creation of dynamic, platform-independent method for building Web-based applications.
What is the difference between Statement, PreparedStatement, CallableStatement?
Statement
PreparedStatement
CallableStatement
What is Java Garbage Collection?
Garbage are unreferenced objects. Garbage Collection is process of reclaiming the runtime unused memory automatically, so Java provides better memory management. It only collections objects that are created by the new keyword. The finalize method is used to perform cleanup processing (destroying remaining objects). You can use the gc() method to invoke garbage collector . Neither finalization nor garbage collection is guaranteed.
What is the final, finalize(), and finally
Final
Finally
Finalize