Important questions and answers for core java
Interview QA

What is JAVA Important Interview Questions For Beginners

Here are some important questions and answers for JAVA

Q.1. What is JAVA?

Ans.Java is a high-level, platform-independent programming language.

Java is collection of various objects. Sun Microsystems created it. Many programmers, web developers, and game developers create programs, websites, and video games using the Java programming language.

Q.2. What characteristics does Java have?

Ans.Java has the following features:
Object-oriented
Inheritance
Encapsulation
Polymorphism
Abstraction
Platform independent
Multi-Threaded

Q.3. How does JAVA support high performance?

Ans.Java uses the Just-In-Time compiler to achieve high performance by transforming the instructions into bytecodes.

Q.4. Name the JAVA IDEs

Ans. The Java IDEs are  Eclipse and NetBeans.

Q.5. What are Constructors in JAVA?

Ans.Whenever a program generates a new object, it calls the appropriate constructor for the class.
A method with the same name as the class is the constructor.
If the user doesn’t explicitly build one, the system will create a default constructor.

It’s possible to overload the constructor.
If a user has established a constructor with a parameter, they should explicitly create another constructor without a parameter.

Q.6.What do the terms “Local variable” and “Instance variable” mean?

Ans. Local variables are defined within the method itself, and their scope is limited to the method.

Instance variables are defined both inside and outside of methods, and the class shares their scope.

Q.7 Define Class?

Ans. In a class, all Java codes are defined.

Variables are characteristics that specify how a class is in a state.

Methods is a place where the business logic is defined. It includes a set of statements (or) instructions to satisfy a particular requirement.

Q.8. Define an Object ?

Ans. Instance of a class is called object.It has state and behavior.
Every time the JVM encounters the “new()” keyword, an instance of that class will be created.

Q.9.What are the concepts of OOPs?

Ans.OOPs concepts are as follows:

Inheritance
Encapsulation
Polymorphism
Abstraction
Interface

Q.10.Define Inheritance?

Ans.Inheritance refers to one class’s ability to extend another class, allowing the transfer of code between classes.We refer to the derived class as a subclass, while we call the original class the superclass.

Q.11.Define Encapsulation?

Ans. Objective of the Encapsulation:
Protects the code from others.
Code maintainability.

Q.12. Define Polymorphism?

Ans.Polymorphism means many forms.
Polymorphism is the ability of a single object to refer to either a super-class or a sub-class depending on the reference type.

Q.13.What does “method overriding” mean?

Ans.The sub-class method and the super-class method must meet the following conditions for method overriding to occur:

The method name should be same.
The case ought to be the same.
Return type ought to be the same as well.
The main advantage of overriding is that it allows the subclass to supply more precise information than the superclass about that subclass type.

Q.14.What does “overloading” mean?

Ans.The correct answer is that method overloading can occur between classes or even inside the same class.

For method overloading, the child-class method together with the parent-class method (or) methods from the same class itself should meet the following requirements:

Same method name
Different argument types
There may be different return types

Q.15.What does “interface” mean?

Ans.In Java, multiple inheritances are not possible. The Interface concept presents a solution to this issue.

An interface is a template that just contains method declarations—not the actual implementation of the methods.

Q.16.What does “Abstract class” mean?

Ans.The “Abstract” keyword placed before the class name allows us to build the Abstract class. Both “Abstract” and “Non-abstract” functions that are of a concrete class can be found in an abstract class.

Abstract Method:

The abstract method  has a declaration and no implementation, and it has the keyword “abstract” in its name. A semicolon marks the end of a declaration.

Q.17.What do the terms “sorted” and “ordered” in collections mean?

Ans:
Ordered: A collection stores values based on the values that have been added to it. Consequently, we are able to iterate the collection’s values in a particular order.

Sorted: You can use sorting techniques internally or externally to organize a collection of things according to their characteristics.

Q.18.What is an exception?

Ans. We call an issue that can arise in the course of normal execution an exception. When something fails during execution, a procedure may throw an exception. If the exception cannot be handled, it stops the execution before completing the task.

If exception is handled, the process returns to normal. A subclass of java.lang is exceptions.Exception.

Q.19.Define Thread in Java?

Ans.In Java, we refer to the flow of execution as a thread. The JVM creates the main thread, which is one of the threads that every Java program has.By extending the Thread class or by implementing the Runnable interface, the user can create their own threads. Concurrent thread execution is used.

Q.20.Describe the wait () Method.

Ans. To make a thread wait in a waiting pool, use the wait () method. When a thread executes the wait () method, the thread instantly relinquishes the lock on the object and moves to the waiting pool. The Wait () function instructs a thread to wait for a specified period of time.

After executing the notify() or notifyAll() method, the thread will reactivate.

Wait() or any of the other methods indicated above do not immediately release the lock on the object until the thread currently running the synchronized code has finished. Most often, synchronisation uses it

If you read more article you can visit on:- softwaretestingleaders

Also you can visit on medium for read story: – Medium.com

Leave a Reply