Menu
Question Index
...

What will be the output of the following program?

class Fruit {
    public void eat() throws Exception {
        System.out.println("Eating fruit");
    }
}
public class Apple extends Fruit {
    public void eat() {
        System.out.println("Eating apple");
    }
    public static void main(String[] args) throws Exception {
        Fruit f = new Apple();
        f.eat();
    }
}


Eating apple
Eating fruit
Eating apple
Eating apple
Eating fruit
Eating fruit
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Exception Handling Syntax In Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App