• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

abstract

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
16. The following code has some errors, select all the correct answers from the following?
public class MyTest {
public void myTest( int i ) {
for ( int x = 0; x < i; x++ ) {
System.out.println( x ) ;
}
}
public abstract void Test() {
myTest(10);
}
}
A) At class declaration
B) myTest() method declaration
C) Test() method declaration
D) No errors, compiles successfully
Answer 16:
C) Test() method declaration
Explanation:
The abstract methods cannot have body. In any class if one method is defined as abstract the class should be defined as abstract class. So in our example the Test() method must be redefined.
-----------
well, i think the correct ans should include A, because it should be declared as abstract class.what do you think?
 
Ranch Hand
Posts: 782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Abstract methods does not have body.That is Test() method is not correct abstract method declaration.If it is declared correct then we will select option A.
Bye.
Viki.
------------------
Count the flowers of ur garden,NOT the leafs which falls away!
reply
    Bookmark Topic Watch Topic
  • New Topic