edited ago by
461 views
1 votes
1 votes

What is the output of the following program?

abstract class sum
{
    public abstract int sumOfTwo(int n1, int n2);
    public abstract int sumOfThree(int n1, int n2, int n3);
    public void disp(){
        System.out.println("Method of class Sum");
    }
}

class DemoAbstract1 extends Sum
{
    public int sumOfTwo(int num1, int num2)
    {
        return num1+num2;
    }
    public int sumOfThree(int num1, int num2, int num3)
    {
        return num1+num2+num3;
    }
    
    public static void main(String args[]){
        Sum obj=new DemoAbstract1();
        System.out.println(obj.sumOfTwo(3,7));
        System.out.println(obj.sumOfThree(4,3,19));
        obj.disp();
    }
}
  1. $10\\26\\\text{Method of class Sum}$
  2. $26\\10\\\text{Method of class Sum}$
  3. $\text{Method of class Sum}\\26\\10$
  4. $\text{Error}$
edited ago by

1 Answer

0 votes
0 votes

Firstly an object of DemoAbstract will be created.

When you call System.out.println(obj.sumOfTwo(3,7)) then it will return 10

When you call System.out.println(obj.sumOfThree(4,3,19)) then it will return 26

Lastly, when you call obj.disp() then "Method of class Sum" will be printed. 

So, Option (A) is Correct.

 

Answer:

Related questions

452
views
1 answers
1 votes
gatecse asked Dec 9, 2020
452 views
Which of the following construct is not supported by Java Server Pages?$\text{JSP}$ Directives$\text{JSP}$ Scriptlets$\text{JSP}$ Actions$\text{JSP}$ Reaction
501
views
1 answers
1 votes
gatecse asked Dec 9, 2020
501 views
The static keyword is used in public static void main() declaration in Java:To enable the $\text{JVM}$ to make call to the main(), as class has not been ... $\text{JVM}$ to make call to the main(), as class has not been finalized
501
views
1 answers
1 votes
gatecse asked Dec 9, 2020
501 views
Which of the following Interface is not supported by $\text{JDBC}$ for connecting to Database in Java Programming language?Statement InterfacePrepared Statement InterfaceCallable Statement InterfaceDatabase Interface
505
views
1 answers
1 votes
gatecse asked Dec 9, 2020
505 views
In the given program:class Dialog1 { public static void main(String args[]) { Frame f1=new Frame("INDIA"); f1.setSize(300,300); f1.setVisible(true); ... are true?f1.setClear(true);f1.setVisible(true);f1.setlook(true);f1.setclean(true);