Beruflich Dokumente
Kultur Dokumente
a) private
b) public
c) protected
d) none of the mentioned
Answer: b
2. Which of these is used to access a member of class before object of that class is created?
a) public
b) private
c) static
d) protected
Answer: c
3. Which of these is used as a default for a member of a class if no access specifier is used for it?
a) private
b) public
c) public, within its own package
d) protected
Answer: a
4. What is the process by which we can control what parts of a program can access the members of a class?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
Answer: c
6. You want subclasses in any package to have access to members of a superclass. Which is the most
restrictive access that accomplishes this objective?
a) public
b) private
c) protected
d) transient
Answer: d
7. Which of these access specifier must be used for class so that it can be inherited by another subclass?
a) public
b) private
c) protected
d) none of the mentioned
Answer: a
8.Given a method in a protected class, what access modifier do you use to restrict access to that method to
only the other members of the same class?
a) final
b) static
c) private
d) protected
Answer: c
11. You want a class to have access to members of another class in the same package. Which is the most
restrictive access that accomplishes this objective?
a) Public
b) Private
c) Protected
d) Default access
Answer:d
a) public
b) private
c) protected
d) transient
Answer:c
Answer:a
b) Compilation fails.
a) 0
b) 1
c) 2
d) Compilation fails.
Answer:d
a) 1 and 3
b) 2 and 4
c) 1 only
18. Which of the following class level (nonlocal) variable declarations will not compile?
a) protected int a;
b) transient int b = 3;
d) volatile int d;
Answer:c