Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Java OCA 考題1 */
- class Super {
- int a = 10;
- public void show() {
- System.out.println("Super class");
- System.out.println("a = " + a);
- }
- }
- class Sub extends Super {
- int a = 50;
- @Override
- public void show() {
- System.out.println("Sub class");
- System.out.println("a = " + a);
- }
- }
- public class MainClass {
- public static void main(String[] args) {
- Super s1 = new Sub();
- System.out.println("s1.a = " + s1.a);
- System.out.printf("\n");
- s1.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement