Menu
Question Index
...

What will be the output of the following program?

class Dog {
    public static void bark() {
        System.out.print("Bow ");
    }
}
class Cat extends Dog {
    public static void bark() {
    }
}
public class Fight {
    public static void main(String args[]) {
        Dog do = new Dog();
        Dog ca = new Cat();
        Dog.bark();
        ca.bark();
    }
}


Bow Bow
Bow Bow Bow
Bow Bow Bow Bow
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App