Important interview QA

Q. What is the difference between an argument and a parameter?
Ans:
While defining method, variables passed in the method are called parameters. While using those methods, values passed to those variables are called arguments.

Q. What are different types of access modifiers?
Ans:
 Public: Anything declared as public can be accessed from anywhere.
Private: Anything declared as private can’t be seen outside of its class.
Protected: Anything declared as protected can be accessed by classes in the same package and subclasses in the other packages.
Default modifier: Can be accessed only to classes in the same package.

Q. What is final, finalize() and finally?
Ans:
final: The final keyword is used to declare constants or final variables, final classes and final methods. The final variable cannot be assigned a value once they are initialized. The final calss cannot be extended and cannot be override the final method.

finalize( ) : finalize( ) method is used just before an object is destroyed and can be called just prior to
garbage collection.
finally : finally, a keyword used in exception handling, creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. 
Q. What is UNICODE?
Ans:
Unicode is used for internal representation of characters and strings and it uses 16 bits to represent each other.

Q. What is Garbage Collection and how to call it explicitly?
Ans: When an object is no longer referred to by any variable, java automatically reclaims memory used by that
object. This is known as garbage collection.
System.gc() method may be used to call it explicitly.

Q. What are Transient and Volatile Modifiers?
Ans:
Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. Transient variables are not serialized.
Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program.
 Q. What is method overloading and method overriding?
Ans:
Method overloading: When a method in a class having the same method name with different arguments or signature is said to be method overloading.

Method overriding : Overridden function is the same name method both in the Base class and in the Derive class. The same name function and same signature of base class is over write in the drive class.
Q. What is Recursion
Recursion is function which call itself. This enables the function to repeat itself several times, outputting the result and the end of each iteration.

SHARE THIS
Previous Post
Next Post