🎴 Flashcard Mode
Programming Language Concepts and History
Card1 / 16
Mastered0
Review0
QuestionClick to flip
What is the result of the following code? 1. public class Drink { 2. private int millis = 200; 3. boolean carbonated = false; 4. 5. public static void main(String [] args) { 6. System.out.println(new AppyFizz()); 7. } 8. } 9. class AppyFizz extends Drink { 10. public String toString() { 11. return millis + " " + carbonated; 12. } 13. }
AnswerClick to flip back
A
Compiler error on line 11
💡 Explanation:
Line 11 fails because millis is private (line 2) and cannot be accessed from subclass AppyFizz. Private members are visible only within their own class. carbonated (line 3) has default access and is visible, but millis causes compilation failure. Option D correctly identifies the error location.