This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "abstract" Watch "abstract" New topic
Author

abstract

wei liu
Ranch Hand

Joined: Dec 06, 2001
Posts: 56
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?
Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
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!


Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining http://groups.yahoo.com/group/IBM340Exam/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: abstract
 
Similar Threads
Reg. abstract class and method
q on abstract class
jargon exam
help me on output of this code
Shallow in static method ?