Can a subclass constructor directly access the private variables of its superclass?
- No
- Only if they are static
- Only if they have the same name
- Yes
No, a subclass constructor cannot directly access the private variables of its superclass. Private variables are not visible to subclasses, so they cannot be accessed or modified directly. Instead, you can use setter and getter methods or make the superclass variables protected or package-private (default) if you need subclass access.
Loading...
Related Quiz
- Lambda expressions are used primarily to define the implementation of ________ interfaces.
- Which of the following expressions will result in a value of true?
- The ________ keyword is used to declare objects that cannot change.
- How can you cancel a task submitted to ExecutorService using Future?
- Consider the code: while(false) { System.out.println("Hello"); }. How many times will "Hello" be printed?