Question: EX 1.4. public class B extends A { Point out the error(s) and how they can be fixed. private int a = 222; ham main

EX 1.4. public class B extends A { Point out the error(s) and how they can be fixed. private int a = 222; ham main la static nen ko the xai thuoc tinh non-static. Thuoc public static void main(String args) { tinh a o' class A vua la private vua la non-static nen cung ko the System.out.printIn("in main(): "); dung duoc. System.out.printIn("a = "+a ); Fix: them static vao truo'c thuoc tinh a o class B thanh static a = 123; private int a=222; hoac them static vao thuoc tinh a trong class A va sua access modifier thanh protected hoac public hoac default public class A { private int a = 100; public void setA( int value) { a = value; public int getA( { return a; } //class A
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
