Professional Documents
Culture Documents
(a) Must have the same name as the class it is declared within.
(b) Is used to create objects.
(c) May be declared private
(d) Both (A) and (B) above
(e) (a), (b) and (c) above.
A constructor is invoked automatically (T/F)?
a) TRUE
b) FALSE
The numeric data members are bydefault initialized as
a) Garbage
b) 0
c) TRUE
d) null
Variables declared as default can be accessible
a) Only in the class
b) Within a package
c) Within a subclass
d) Outside of a package
Private members of a class are accessible in another class
directly (T/F)
a) TRUE
b) FALSE
What is true about constructor?
a) It can contain return type
b) It can take any number of parameters
c) It can have any non access modifiers
d) Constructor cannot throw an exception
What is the output of the following
class T {
int t = 20;
}
1. 0
class Main {
2. 20
public static void main(String args[]) {
3. Compiler error
T t1 = new T();
4. Runtime error
System.out.println(t1.t);
}
}
‘This’ keyword is used to differentiate instance variables and
local variable having the same name(T/F)
a) TRUE
b) FALSE
is the return type of a method can be used to distinguish
overloaded methods(T/F)
a) TRUE
b) FALSE
Which of the following is True?