Random Flashcards
class ?
Collection of objects is called class.
object ?
- An Object can be defined as an instance of a class.
or - a real-world entity
Inheritance ?
process of one class acquiring the properties of another classes
Polymorphism in Java ?
Polymorphism is the ability of an object to take many forms.
Abstraction ?
hiding the unnecessary details
Encapsulation ?
Encapsulation in Java is a mechanism to wrap up variables(data) and methods(code) together as a single unit.
Why is multiple inheritance not supported in Java?
?
Can we override the static method?
NO.
Static methods cannot be overridden because they are not dispatched on the object instance at runtime. The compiler decides which method gets called.
Can we overload the main method?
Yes, We can overload the main method in java but JVM only calls the original main method, it will never call our overloaded main method.
A Java Constructor returns a value but, what?
There are no “return value” statements in the constructor, but the constructor returns the current class instance.
Can we overload a static method?
Yes. We can overload static methods. But remember that the method signature must be different. For example, consider the following Java program.
Constructors?
- It is used to initialize the object.
- It calls a default constructor if there is no constructor available in the class.
static vs final?
- static is used to define the class member that can be used independently of any object of the class
- while final is used to declare a constant variable or a method that cannot be overridden or a class that cannot be inherited.
Multiple inheritance in java?
Java does not support Multiple inheritance.