200 Most Frequenty Asked Core Java Interview Questions – OOPs

Core Java Interview Questions

1. What do you understand by Java?

Java is an object-oriented and platform independent programming language. Java runs on a various of platforms such as Mac OS, Windows, and UNIX. Some features of java are Object Oriented, Platform Independent, Secure, Robust, Portable, Interpreted, Dynamic, Multi-threaded.

2. Differentiate between JVM, JDK and JRE?

JVM stands for Java Virtual Machine which provides the runtime environment for compiled Java Bytecode. JVM is responsible for convert the byte code into machine readable code.

JDK stands for Java Development Kit consists of JRE including development tools for development purpose. Which required to write and execute a java code.

JRE stands for Java Runtime Environment that includes sets of files required by JVM during runtime.

3. Is JVM’s platform independent?

JVM is not platform independent. So we need different JVM for different operating systems. Windows JVM can not be run on Linux.

4. What do you mean by platform independence?

Platform independence means we can write and compile the java source code in one platform and execute on another platform.

5. Why main() method is static?

Because of an object not required to call the static method in java.

6. How To declare the main method as a final method?

public static final void main(String args[])

7. Can we execute a program without a main() method?

Yes with the help of static block.

8. What is a static block in java?

Static block used to initialize the static data member.

9. Which class is the superclass of all class?

The Object class.

10. What is this in java?

In java, this is a keyword that refers to the current object.

11. What is a super keyword in java?

The super keyword refers to parent class object.

12. What is Bytecode?

Java byte code is machine code contains set of instruction in form of .class file. This .class file is executed by java virtual machine.

13. How many types of memory used by JVM?

Class Area, Heap, Stack, Register, Native Method Stack.

14. What is a JIT compiler?

JIT compiler stands for Just In Time compiler. It is used to improves the performance of Java applications by compiling bytecodes to native machine code instruction at a run time. It is a part of JVM.

15. What is classloader?

A class loader is an object that is used to loading classes and interfaces. Classloader considered as a subsystem of JVM. The class ClassLoader is an abstract class. We can create our own classloader by the overriding loadClass(String name) method and extend ClassLoader class. There are many types of class loaders like System classloader, Bootstrap classloader, Extension class loader, Plugin classloader.

16. Why is Java ‘write once and run anywhere’ nature?

Java byte code is machine code contains set of instruction in form of .class file which is not executable code. This byte code is platform independent code can be run on any platform. Bytecode is intermediate language between java source code and machine readable code.

17. What is a platform?

A platform is an environment in which a program runs. There are two types of platforms available are hardware based and software based platform.

18. What is blank final variable?

If a final variable is not initialized at a time of declaration then it is called as a blank final variable.

19. What is a final class?

A final class can not inherit, other classes.

20. What is final variable?

The value of the variable can not be change if you make a variable final.

21. What is the final method?

The final method can not override.

22. Functions in java are virtual or not?

All the functions in java are by default virtual.

23. How to initialize a blank final variable.

We can initialize a blank final variable in the constructor if it is nonstatic.

24. Is it possible to override static method in java?

No, it is not possible to override static method in java. Because of a static method is part of the class.

25. Can we override the overloaded method?

Yes, it is possible.

26. Can we overload a main() method in java?

Yes.

27. What is object cloning?

Object cloning means to create a copy of an object.

28. It is possible to use this() and super() both at the same time in a constructor?

No.

29. What is a difference between aggregation and composition?

The composition represents strong relationship and aggregation represents a weak relationship.

30. Why are multiple inheritances not supported in java?

Multiple inheritances not supported in java for reducing the complexity of the language.

31. Can we make a constructor final?

No.

32. Constructor return any value or not?

Yes.
Directory Business Site

Categories: Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *