Sapient Company Programming

Which of the following statements is/are correct regarding inheritance in Java?

A. Private methods cannot be overridden.
B. Inherited classes are not accessible outside a package.
C. Protected methods are final while private methods are not.

1) Statement A is wrong
2) Statement B is wrong
3) Statement C is correct
4) Statement B is correct but Statement C is wrong.

Read Solution (Total 2)

Sapient Other Question

In Java______ is related to compile time polymorphism, while______ is related to run time polymorphism.

1) Overloading, inheritance
2) Inheritance, Overriding
3) Overloading, Overriding
4) Overriding, Overloading
What should be the access specifiers for function Bob() in the following code snippet so that the program doesn't get compiler error?

class Base{
---1--- void Bob(){}
}

class Derived extends Base{
---2--- void Bob(){}
}

public class Main{
public static void main(String args[]){
Derived d = new Derived();
}
}

1) 1=public 2=protected
2) 1=public 2=private
3) 1=private 2=public
4) 1=private 2=protected