0 votes
in JAVA by
What will be the output of the following program?

abstract class MyFirstClass  

{  

     abstract num (int a, int b) {  }  

}  

a) No error

b) Method is not defined properly

c) Constructor is not defined properly

d) Extra parentheses

1 Answer

0 votes
by

(b) Method is not defined properly.

Reason: Following are some rules for declaring an abstract method:

  • Abstract methods do not specify a method body, but they only have a method signature.
  • Abstract methods are always defined inside an abstract class.

In the above code, MyFirstClass is an abstract class. It contains an abstract method named num() that is not defined properly. According to the rules discussed above, an abstract method only has a method signature, not the method body.

Related questions

0 votes
asked Apr 10, 2021 in JAVA by Robindeniel
0 votes
asked Apr 10, 2021 in JAVA by Robindeniel
...