Interview Questions - Java Basics
29.
Can a top level class be private or protected?
No. A top level class cannot 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.
30.
What type of parameter passing does Java support?
In Java the arguments are always passed by value.
31.
Primitive data types are passed by reference or pass by value?
Primitive data types are passed by value.
32.
Objects are passed by value or by reference?
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.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers