File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dan's exam2: abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dan Watch "Dan New topic
Author

Dan's exam2: abstract

Ming Tan
Greenhorn

Joined: Jan 09, 2003
Posts: 23
In Q8, the question asks which statement would generate compilation error? Dan's answer is //2, my compilar says none, what will Sun Exam say?
(I understand that it doesn't make sense to use strictfp in an abstract method)
abstract class A { // 1
abstract strictfp void m1(); // 2
abstract strictfp class B {} // 3
strictfp class C extends B {} // 4
}
Md.Afzalur Rashid
Ranch Hand

Joined: Oct 29, 2002
Posts: 47
I think it must be //2 only bcause abstract is used only in class declaration so according to me //2 is the answer......
Thanks


Be Confident,be trusty,Count your age by friends not by years
sun par
Ranch Hand

Joined: Oct 03, 2002
Posts: 257
Abstract can be used in method declarations. It means that the enclosing class is abstract and the implementation of the class is provided in subclass unless it declares the method abstract again.


Sunita<br />SCJP 1.4
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Ming,
Section 8.4.3 of the java language specification requires that a compile-time error must be generated due to the illegal combination of modifiers.

A compile-time error occurs if a method declaration that contains the keyword abstract also contains any one of the keywords private, static, final, native, strictfp, or synchronized.

What compiler are you using?
After I developed the questions involving the use of strictfp I found that the real exam does not cover that modifier so the real exam won't have a question like this one.
For those that are interested, I will quote the explanation associated with the answer.

The strictfp modifier in a superclass declaration has no impact on an overriding method in a subclass. For that reason, it makes no sense to include the strictfp modifier in an abstract method declaration. By generating a compile time error, the compiler reminds the programmer of the futility of combining the abstract and strictfp modifiers. A class, however, may be both abstract and strictfp. When applied to a class, the strictfp modifier causes all float and double expressions within the class to be strictfp. This implies that all float and double expressions are strictfp in all nested classes, methods, constructors and all static, instance, and variable initializers. The declaration of an abstract method in a strictfp class is entirely legal even though the implementation of the method in a subclass need not be strictfp.


Dan Chisholm<br />SCJP 1.4<br /> <br /><a href="http://www.danchisholm.net/" target="_blank" rel="nofollow">Try my mock exam.</a>
Ming Tan
Greenhorn

Joined: Jan 09, 2003
Posts: 23
I am using jdk 1.3.1. May be that's the problem. I am doing 80% in your mock exams and the real exam is this saturday, do you think I am good to go?
Dan Chisholm
Ranch Hand

Joined: Jul 02, 2002
Posts: 1865
Originally posted by Ming Tan:
I am using jdk 1.3.1. May be that's the problem. I am doing 80% in your mock exams and the real exam is this saturday, do you think I am good to go?

Based on the feedback that I have received a score of 80% on my exam is very high. I'm sure that you won't have any problems with the real exam.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dan's exam2: abstract