File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dan's exam2: abstract

 
Ming Tan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it must be //2 only bcause abstract is used only in class declaration so according to me //2 is the answer......
Thanks
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ming Tan
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1865
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic