Friday, October 18, 2019

Java Programming interview questions

Java Programming interview questions

Java Programming interview questions


Java Programming Interview Questions

Here we provide most asked interview questions which is more helpful to crack  any interview of java programming.


1. What is JVM?  Why is Java called a platform-independent programming language?Guess?


Ans.


A Java Virtual Machine (JVM) is a virtual process engine that can execute Java bytecode.  


Each Java source file is compiled

into a bytecode file executed by the JVM. Java has been designed to enable the creation of application programs that are possible
Run on any platform without the programmer having to rewrite or compile it for each platform.  

A virtual Java Machine makes this possible because it knows the specific command lengths and other peculiarities of the underlying Hardware platform.




2. What are the difference between JDK and JRE?


Ans.


The Java Runtime Environment (JRE) is basically the Java Virtual Machine (JVM) that runs your Java programs.


It also contains browser plugins for running applets. The Java Development Kit (JDK) is fully functional software development Kit for Java, including JRE, compilers and tools (such as JavaDoc and Java Debugger for a user to develop and compile Run Java applications.




3. What does the keyword "static" mean? Should we override private or static Method in Java?


Ans.


The static keyword indicates that a member variable or method can be accessed without requiring instantiation of the class what it belongs.  A user can not override static methods in Java because overriding methods is based on dynamic binding.


Runtime and static methods are statically bound during compilation. The Static method is not associated with any instance of a class

So the concept is not applicable.



4. Can you access non-static variables in the static context?


Ans.


A static variable in Java belongs to its class and its value remains the same for all instances.  A static variable is initialized

when the class is loaded by the JVM.  

If your code attempts to access a non-static variable without an instance, the compiler will do it Complain because these variables have not yet been created and are not associated with any instances.