JVM is an acronym for Java Virtual Machine, it is an abstract machine which provides the runtime environment in which java bytecode can be executed. It is a specification.java
JVMs are available for many hardware and software platforms (so JVM is platform dependent).swift
JRE stands for Java Runtime Environment. It is the implementation of JVM.jvm
JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools.ide
Many types:post
Just-In-Time(JIT) compiler:It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term 「compiler」 refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.this
A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform.google
The Java platform differs from most other platforms in the sense that it's a software-based platform that runs on top of other hardware-based platforms.It has two components:spa
The bytecode. Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platform specific and hence can be fed to any platform.
The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.
Yes, save your java file by .java only, compile it by javac .java and run by java yourclassname Let's take a simple example:
compile it by javac .java
run it by java A
No.
It is empty. But not null.
Program compiles and runs properly.
The local variables are not initialized to any default value, neither primitives nor object references.
There is given more than 50 OOPs (Object-Oriented Programming and System) interview questions. But they have been categorized in many sections such as constructor interview questions, static interview questions, Inheritance Interview questions, Abstraction interview question, Polymorphism interview questions etc. for better understanding.
Object based programming languages follow all the features of OOPs except Inheritance. Examples of object based programming languages are JavaScript, VBScript etc.
The object references are all initialized to null in Java.
Ans:yes, that is current instance (You cannot use return type yet it returns a value).more details...
No, constructor is not inherited.
No, constructor can't be final.
because object is not required to call static method if It were non-static method,jvm creats object first then call main() method that will lead to the problem of extra memory allocation.more details...
Ans) Yes, one of the way is static block.more details...
Program compiles. But at runtime throws an error "NoSuchMethodError".
static or class method | instance method |
---|---|
1)A method i.e. declared as static is known as static method. | A method i.e. not declared as static is known as instance method. |
2)Object is not required to call static method. | Object is required to call instance methods. |
3)Non-static (instance) members cannot be accessed in static context (static method, static block and static nested class) directly. | static and non-static variables both can be accessed in instance methods. |
4)For example: public static int cube(int n){ return n*n*n;} | For example: public void msg(){...}. |
It is a keyword that that refers to the current object.more details...
Inheritance is a mechanism in which one object acquires all the properties and behaviour of another object of another class. It represents IS-A relationship. It is used for Code Resusability and Method Overriding.
Object class.
Holding the reference of the other class within some other class is known as composition.
Aggregation represents weak relationship whereas composition represents strong relationship. For example: bike has an indicator (aggregation) but bike has an engine (compostion).
Pointer is a variable that refers to the memory address. They are not used in java because they are unsafe(unsecured) and complex to understand.
It is a keyword that refers to the immediate parent class object.more details...
No. Because super() or this() must be the first statement.
The object cloning is used to create the exact copy of an object. more details...
If a class have multiple methods by same name but different parameters, it is known as Method Overloading. It increases the readability of the program.more details...
Becauseof ambiguity.more details...
Yes, You can have many main() methods in a class by overloading the main method.
If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding. It is used for runtime polymorphism and to provide the specific implementation of the method.more details...
No, you can't override the static method because they are the part of class not object.
It is because the static method is the part of class and it is bound with class whereas instance method is bound with object and static gets memory in class area and instance gets memory in heap.
Yes.
Method Overloading | Method Overriding |
---|---|
1) Method overloading increases the readability of the program. | Method overriding provides the specific implementation of the method that is already provided by its super class. |
2) method overlaoding is occurs within the class. | Method overriding occurs in two classes that have IS-A relationship. |
3) In this case, parameter must be different. | In this case, parameter must be same. |
Yes, all functions in Java are virtual by default.
Now, since java5, it is possible to override any method by changing the return type if the return type of the subclass overriding method is subclass type. It is known as covariant return type. more details...
If you make any variable as final, you cannot change the value of final variable(It will be constant).more details...
Final methods can't be overriden.more details...
Final class can't be inherited. more details...
A final variable, not initalized at the time of declaration, is known as blank final variable.more details...
Yes, only in constructor if it is non-static. If it is static blank final variable, it can be initialized only in the static block.more details...
Yes, such as, public static final void main(String[] args){}.