Top 20 Freshers Java Basic Interview Questions
Q1. What is the most Important feature of java?
Ans: Java is platform independent language.
Q2. What is platform?
Ans: A platform is basically the hardware or software environment in which a program runs.
There are two types of platforms software and hardware.
Java provides software-based platform.
Q3. What do you mean by Platform Independence?
Ans: Platform Independence you can run and compile program in one platform and can execute in any other platform.
Q4. What is the base class of all classes?
Q5. What is JIT Compiler?
Ans: Just-In-Time(JIT) compiler is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time,
Q6. What is JVM(Java Virtual Machine)?
Ans: JVM is Java Virtual Machine which is a run time Environment for the compiled java class.
Q7. Are JVM’s Platform Independent?
Ans: JVM’S are not platform Independent. JVM’S are platform Specific.
Q8. What if main method declare as private?
Ans: No,It will compile fine but in run time it will error like main method should be in public.cannot find main method.
Q9. What are two different ways to call garbage collector?
Ans: System.gc() OR Runtime.getRuntime().gc().
Q10. What all memory areas are allocated by JVM?
Ans: Heap, Stack, Program Counter Register and Native Method Stack
Freshers Java basic Interview questions
Q11. Can we override a static method?
Ans: No, we cannot override a static method. Static means class level.
Q12. List two java ID Es?
Ans: 1.Eclipse, 2.Net beans and 3.IntelliJ
Q13. Use of finalize() method in java?
Ans: finalize() method is used to free the allocated resource.
Q14. What is javac ?
Ans: It produces the java byte code from *.java file.
It is the intermediate representation of your source code that contains instructions.
Q15. Is it possible to overload main() method of a class?
Ans: Yes, we can overload main() method as well.
But every time public static main(String args) will be called automatically by JVM.
Other methods need to call explicitly.
Q16. Does Java support operator overloading?
Ans: Operator overloading is not supported in Java.
Q17. Can I declare a data type inside loop in java?
Ans: Any Data type declaration should not be inside the loop. Its possible but not recommended.
We can call super class constructors from subclass constructor by using super() call.
Q18. Can we mark constructors final?
Ans: No, Constructor cannot be declared final.
Q19. Can this keyword be assigned null value?
Ans: No, this keyword cannot have null values assigned to it.
Q20. Can we inherit the constructors?
Ans: No, we cannot inherit constructors.