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 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 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
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
What is the difference between String, StringBuilder and StringBuffer?
String
StringBuffer
StringBuilder
What is the difference between static and final variables?
Static
Final
What are the implicit modifiers require for interface variables?
Public
Static
Final
What are transient variables?
The transient keyword in Java is used to indicate that a field should not be serialized. Variables marked transient to indicate that they are not part of the persistent state of an object.
What are access modifiers?
Access modifiers in Java specifies the scope (accessibility) of a data member, method,constructor or class.
Private
Default
Protected
Public
1. Accessible everywhere
What is a wrapper class?
Wrapper class (Integer, Long, Byte, Double, FLoat, Short) are subclasses of the abstract class Number. It converts primitive types into objects called boxing and converted back to primitive type called unboxing.
What is Reflection API?
Java Reflection is a process of examining or modifying the run time behavior of a class at run time. The Class class provides many methods that can be used to get metadata, examine and change the run time behavior of a class. It is mainly used in IDE, Debugger, Test Tools.