Menu
Question Index
...

What will be the output of the following program?

class Person {
    public void talk() {
        System.out.print("First Program");
    }
}
class Student extends Person {
    public void talk() {
        System.out.print("Second Program");
    }
}
public class TestProgram {
    public static void main(String args[]) {
        Person p = new Student();
        p.talk();
    }
}


First Program
Second Program
First ProgramSecond Program
Second ProgramFirst Program
Compilation Error or Runtime Error

Doubts

Problems

Topic: Method Overriding In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App