Quiz 2 : Access Modifiers
Graded Quiz • 30 min Quiz08 Questions Week 1
Re⥃askly Logo

Quiz 2 : Access Modifiers

Graded Quiz • 30 min Quiz08 Questions Week 1
Practice More Quizzes:
Quiz
08 Questions Week 1
Quiz
7 Questions Week 2
Quiz
8 Questions Week 3
Quiz
Quiz
07 Questions Week 4

Q:

Can a subclass inherit a private member of its parent class?

Q:

We can’t declare private variables in a child class because its parent class should have access to every variable in the child class.

Q:

Which type of variable or method can only be accessed from within the current package?

Q:

Which of the following must be used for the main() method?

Q:

Which fields in class A can be inherited in class B in the code below if A and B are in the same package? class A { protected int a; public int b; private int c; int d; } class B extends A {}

Q:

What is the output for the following code? class A { private int number; public String name; private void display() { System.out.print(“One”); } public String printname(String name) { this.name = name; System.out.print(name); return name; } } public class B { public static void main(String[] args) { A a = new A(); a.display(); a.printname(“Aa”); } }

Q:

Which type of variable or method can only be accessed from within the same package or sub classes in a different package?

Q:

What is the output of the following code? class A { protected void display() { System.out.print(“One”); } } public class B extends A { void display() { System.out.print(“Two”); } public static void main(String[] args) { B b = new B(); b.display(); } }

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Find Questions in This Page: "CTRL+F"