Every one of us has heard of Java even though we may not know exactly what it means or does. And this is because of the huge number of applications of this programming language. Java finds its use in games, desktop applications, and mobile systems among many others. And if you are seeking a job in the IT industry, it is almost imperative that you have a basic understanding of Java.
Here are 20 of the most frequently asked basic Java interview questions and answers, that can help you prepare for an interview regardless of which language you are proficient in.
- What do you think are the advantages of using Java?
Java is a high-level object-oriented programming language used for developing games, device systems, and applications.
It is secure, fast, reliable, portable and platform independent.2. What do you understand by Object and Class?
An object is understood as a collection of methods and classes which represent its state and executes operations.
A class is used to define new types of data which in turn is used to create objects.3. What are JVM, JDK, and JRE?
• JVM (Java Virtual Machine) offers the runtime environment for codes to be executed.
• JRE (Java Runtime Environment) is the collection of files needed during runtime by JVM.
• JDK (Java Development Kit) is needed to write and execute a program and contains the JRE with necessary development tools.4. What is meant by looping?
Loops are used to repeatedly execute a certain statement or block of statements.
They are of three types- For Loops, While Loops and Do While Loops.
Did you know: Java Developer Job is the 2nd best job in the US according to Glassdoor’s 2020 list of 50 Best Jobs in America.
5. What is the difference between Overloading and Overriding?
When you have two methods of the same name but having different properties, the case is called Overloading. On the other hand, Overriding refers to a situation where two methods with the same name and properties occur, but the two occurring in a parent and child class respectively.6. What is Inheritance?
Inheritance allows you to let a derived class acquire the methods from a base class.7. Is it possible to restrict Inheritance?
Yes, it is. You can restrict Inheritance by:
a. Using the final keyword.
b. Making the method final.
c. Using private constructor.
d. Using (//) Javadoc comment.8. What do you mean by Content Negotiation?
Content negotiation occurs between you as a user and the host server. For instance, when you make an HTTP request you receive your result in different languages and formats, and you can specify what content you will accept back from the host in a negotiation of the type of content shared.9. What is WORA?
WORA or Write Once Read Anywhere, is the property of a language to run on any platform. Java is allowed this property due to its bytecode nature. This is midway between machine code and source code and is thus not platform specific.10. What is the function of ClassLoader?
You can use ClassLoader to load class files before running the java program.
You may also like: Tips to Unlock the Interview Process for Java Jobs
11. What are static methods and static variables?
They are methods and variables shared by all the objects in a class. Their static nature is a character of the class and not the object itself.12. What do you understand by the Object-Oriented Paradigm?
When your programming paradigm is dependent on objects containing data with methods defined within the class to which they belong, it is referred to as Object Oriented Paradigm.13. Is there a difference between Object Oriented and Object-Based language?
Object Oriented languages such as Java and C++ follow all the concepts of an Object Oriented Program and do not have inbuilt objects.
Object-Based languages like JavaScript do not follow all OOPs concepts-such as inheritance-and do have I built objects.14. What is the function of a constructor?
You can use constructors to initialize the state of any object. When you create a new object using a new keyword, a default constructor is invoked. This must have a name similar to the class name.15. How do you use ‘this’ keyword?
You can use ‘this’ to refer to a current object, invoke the current class method or class constructor. You can also pass it on as an argument into your methods or constructors.16. What is aggregation?
It is a type of weak relation you can create between two classes, where one contain references to another class contained within it.17. What is the purpose of composition?
You can use composition to hold the reference of one class within another class, and in this case, the contained object cannot exist without the class containing it. It is a type of aggregation.18. What is annotation?
Annotation is a tag you use to symbolize metadata that represents your class, interface, and fields among others.
They are used by the compiler and the JVM and don’t directly influence the operations.19. What is enumeration?
It is an interface you can use to access original data structure from which the enumeration is obtained.20. What is the function of Synchronized Block?
While its scope is smaller than method, you can use it to lock an object for each shared resource.
Looking for Java Jobs in top cities? Click at the links below:
More Resources : Job vacancies in Chennai | Job vacancies in Agra | Resignation format | Java Interview questions for 5 years Experience