Practice More Quizzes:
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
0 Comments
Find Questions in This Page: "CTRL+F"