Set - 9

Question 36 :

What is the default value of an object reference declared as an instance variable?

Answer :

Null unless we define it explicitly.


Question 37 :

Can a top level class be private or protected?

Answer :

No. A top level class can not be private or protected. It can have either "public" or no modifier. If it does not have a modifier it is supposed to have a default access.If a top level class is declared as private the compiler will complain that the "modifier private is not allowed here". This means that a top level class can not be private. Same is the case with protected.


Question 38 :

What type of parameter passing does Java support?

Answer :

In Java the arguments are always passed by value .


Question 39 :

Primitive data types are passed by reference or pass by value?

Answer :

Primitive data types are passed by value.


Question 40 :

Objects are passed by value or by reference?

Answer :

Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to the same object .