Term
What is the difference between static methods and instance methods? |
|
Definition
instance method belongs to the instance of a class therefore it requires an instance before it can be invoked, whereas static method belongs to the class itself and not to any class instance so it doesn’t need an instance to be invoked. |
|
|
Term
Can static block throw exception? |
|
Definition
Yes, static block can throw only Runtime exception or can use a try-catch block to catch checked exception |
|
|
Term
What is difference between abstract class and interface? |
|
Definition
A class is called abstract when it contains at least one abstract method. Interface can contain only abstract( non implemented) methods. |
|
|
Term
describe when to use abstract class and interface? |
|
Definition
When we talk about abstract classes we are defining characteristics of an object type, specifying what an object is but in the case of an interface we define a capability and we bond to provide that capability, we are talking about establishing a contract about what the object can do. |
|
|
Term
Does java support multiple inheritance? |
|
Definition
Java doesnt support multiple inheritance. |
|
|
Term
Can the this keyword be assigned a null value? |
|
Definition
|
|
Term
What are the different types of references in java? |
|
Definition
Strong Reference, Soft Reference ,Weak Reference ,Phantom Reference |
|
|
Term
Does java support pass by value or pass by reference? |
|
Definition
Java supports only pass by value |
|
|
Term
|
Definition
you are passing a copy of the variable. |
|
|
Term
what is pass by reference? |
|
Definition
you are passing a pointer to the variable |
|
|
Term
What is the difference between equals() and ==? |
|
Definition
== operator is used to compare the references of the objects. equals() method can be used to compare the values of two objects |
|
|