What is Java? Java is an object-oriented, high-level programming language that is used to develop robust and secure applications. It was first released by Sun Microsystems in 1995 and is now owned by Oracle Corporation.
What are the key features of Java? Java has several key features, including platform independence, automatic memory management, multi-threading support, security, and robustness.
What is the difference between an abstract class and an interface in Java? An abstract class can have both abstract and non-abstract methods, whereas an interface can only have abstract methods. An abstract class can also have instance variables, whereas an interface can only have static constants.
What is the difference between a constructor and a method in Java? A constructor is a special method that is called when an object is created. It is used to initialize the object’s state. A method is a function that is called on an object to perform some operation.
What is the difference between static and non-static methods in Java? A static method belongs to the class and not to any particular instance of the class. It can be called using the class name. A non-static method, on the other hand, belongs to a specific instance of the class and can only be called on that instance.
What is the difference between final, finally, and finalize in Java? Final is used to declare a constant variable or to make a method or class immutable. Finally is a block of code that is executed after a try-catch block, regardless of whether an exception is thrown or not. Finalize is a method that is called by the garbage collector when an object is about to be destroyed.
What is a JVM? A JVM, or Java Virtual Machine, is a software that interprets compiled Java code and executes it on the underlying platform. It is responsible for managing memory, running threads, and providing security to the Java applications.
What is a thread in Java? A thread is a lightweight process that runs concurrently with other threads in a Java application. It is used to perform multiple tasks simultaneously and can improve the performance of an application.
What is the difference between an array and an ArrayList in Java? An array is a fixed-size data structure that can hold a collection of values of the same type. An ArrayList is a dynamic data structure that can hold a collection of values of any type and can grow or shrink in size as needed.
What is the difference between a checked and an unchecked exception in Java? A checked exception is a type of exception that must be declared in the method signature or handled by a try-catch block. An unchecked exception, on the other hand, does not need to be declared or caught explicitly. Examples of checked exceptions include IOException and SQLException, while examples of unchecked exceptions include NullPointerException and ArrayIndexOutOfBoundsException.