img
Java

Java is a versatile programming language used for developing a wide range of applications. It offers strong support for object-oriented programming and is known for its robustness and scalability. Java is widely employed by companies across industries.

Last updated on:- 12th June 2023


1.
What is Java ?

Java is a high-level, object-oriented programming language developed by Sun Microsystems. It is designed to be platform-independent and runs on a wide range of devices, including computers, mobile phones, and embedded systems.

2.
What is the difference between JDK, JRE, and JVM ?

JDK (Java Development Kit) is a software development kit that includes the necessary tools, libraries, and documentation to develop Java applications. JRE (Java Runtime Environment) is a runtime environment that provides the necessary libraries and files for executing Java applications. JVM (Java Virtual Machine) is an abstract machine that provides the runtime environment for executing Java bytecode.

3.
What are the features of Java ?

Java has several features, including object-oriented programming, platform independence, automatic memory management (garbage collection), strong type checking, exception handling, and multithreading support.

4.
What is the difference between abstract classes and interfaces in Java ?

Abstract classes can have both abstract and non-abstract methods, while interfaces can only have abstract methods. A class can implement multiple interfaces, but it can only extend a single abstract class.

5.
What is the difference between a class and an object in Java ?

A class is a blueprint or template that defines the properties and behaviors of objects. An object is an instance of a class, created using the 'new' keyword. Multiple objects can be created from a single class.

6.
What is the use of the 'static' keyword in Java ?

The 'static' keyword is used to define class-level members that are shared among all instances of a class. Static variables and methods can be accessed without creating an instance of the class.

7.
What is the difference between '==' and '.equals()' in Java ?

'==' is used to compare the reference equality of two objects, while '.equals()' is used to compare the content equality of two objects. '.equals()' method needs to be overridden in custom classes to provide meaningful comparison.

8.
What is the purpose of the 'final' keyword in Java ?

The 'final' keyword can be applied to variables, methods, and classes. A final variable cannot be changed once assigned, a final method cannot be overridden in subclasses, and a final class cannot be inherited.

9.
What is the difference between checked and unchecked exceptions in Java ?

Checked exceptions are checked at compile-time and need to be handled using try-catch blocks or declared in the method signature using the 'throws' keyword. Unchecked exceptions are not checked at compile-time and do not require explicit handling.

10.
What are the access modifiers in Java ?

Java has four access modifiers: public, protected, default (package-private), and private. These modifiers control the visibility and accessibility of classes, methods, and variables.

11.
What is the difference between the 'final', 'finally', and 'finalize' keywords in Java ?

'final' is used to declare a constant value, 'finally' is a block that is always executed after the try and catch blocks, and 'finalize' is a method called by the garbage collector before reclaiming an object's memory.

12.
What is the Java Virtual Machine (JVM) ?

The Java Virtual Machine (JVM) is an abstract machine that provides the runtime environment for executing Java bytecode. It provides memory management, garbage collection, and other essential runtime services.

13.
What is the difference between method overloading and method overriding ?

Method overloading is defining multiple methods with the same name but different parameters in the same class. Method overriding is providing a different implementation of a method in a subclass, which is already defined in its superclass.

14.
What are constructors in Java ?

Constructors are special methods that are used to initialize objects. They have the same name as the class and do not have a return type. Constructors can be used to set initial values for object properties.

15.
What is the 'this' keyword in Java ?

The 'this' keyword refers to the current instance of a class. It is used to access instance variables and methods within the class, differentiate between instance variables and local variables, and invoke one constructor from another using constructor chaining.

16.
What is method overloading in Java ?

Method overloading is the ability to define multiple methods with the same name but different parameters in the same class. The compiler selects the appropriate method to execute based on the arguments provided during method invocation.

17.
What is the purpose of the 'super' keyword in Java ?

The 'super' keyword is used to refer to the superclass of a subclass. It can be used to call the superclass constructor, access superclass methods or variables, and differentiate between overridden and superclass methods with the same name.

18.
What is method overriding in Java ?

Method overriding is the ability to provide a different implementation of a method in a subclass, which is already defined in its superclass. The method in the subclass must have the same name, return type, and parameters as the method in the superclass.

19.
What is the purpose of the 'package' statement in Java ?

The 'package' statement is used to define a package, which is a way to organize related classes and interfaces into a single namespace. It helps in avoiding naming conflicts and provides better code organization and modularity.

20.
What are Java annotations ?

Java annotations are metadata tags that provide additional information about code elements such as classes, methods, and variables. They can be used for various purposes like providing compiler instructions, runtime information, or generating documentation.
img

"Embrace curiosity, unlock knowledge"

Copyright © 2023 - Some rights reserved

Made with

in INDIA