Forums Register Login

final,abstract and strictfp

+Pie Number of slices to send: Send
Hi folks,

Which of the following declarations are correct w.r.t. final, abstract and strictfp ?

(a) public final class xyz {}
(b) public abstract class xyz {}
(c) strictfp final class xyz {}
(d) final abstract class xyz {}


Bye,
Ravi Kumar
[ October 29, 2007: Message edited by: raavi kumaar ]

[ October 29, 2007: Message edited by: Ilja Preuss ]

Answer to the above question-

Option (a) - Correct, It is a final class declaration

Option (b) - Correct, It is an abstract class declaration.

Option (c) - Correct, strictfp can be applied to classes and methods, but not variables. Try this example -

public strictfp class Airplane {

//uncomment the below line and try compiling the code
//strictfp int x=10;
public strictfp void takeoff (){}

public strictfp void fly () {}

public strictfp void land(){}
}


Option (d) - Incorrect, Going by definition, final classes cannot be extended while abstract classes must be implemented ( by concrete classes ). Given this information , it is illegal (and of course invalid) to have final and abstract in the same declaration.

[ October 30, 2007: Message edited by: raavi kumaar ]
[ October 30, 2007: Message edited by: raavi kumaar ]
+Pie Number of slices to send: Send
a and b are correct

d is wrong because a class cannot be both final and abstract it can be either final or abstract
[ October 29, 2007: Message edited by: abhishek pendkay ]
+Pie Number of slices to send: Send
only (d) final abstract class xyz {} is wrong.
a,b and c are right.
+Pie Number of slices to send: Send
d. is invalid
A class can not be both final and abstract.
+Pie Number of slices to send: Send
Ravi,

I deleted your email address, because we want to foster discussion on these forums, so that everyone can benefit from it. If you want to be notified when someone replies to this thread, please use the watch feature of this forum.

Also take a look at http://faq.javaranch.com/java/UseTheForumNotEmail and http://faq.javaranch.com/java/DoYourOwnHomework. I'm positive that taking those tips into account will improve your experience here on the Ranch.

Have fun, Ilja
+Pie Number of slices to send: Send
 

Originally posted by satyabrat mishra:
only (d) final abstract class xyz {} is wrong.
a,b and c are right.



You are right Satyabrat!!!

Ravi
http://www.devsquare.com/adc/dsweb/
[ October 29, 2007: Message edited by: raavi kumaar ]
+Pie Number of slices to send: Send
 

Originally posted by sudhir nim:
d. is invalid
A class can not be both final and abstract.



Kudos, you are right Sudhir.

Ravi
http://www.devsquare.com/adc/dsweb/
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1348 times.
Similar Threads
Question - Philip Heller's book
Non access modifier strictfp and intefaces
strictfp
will this class compile?
Inner classes
Sybex OCA Chapter 5 #15 Errata?
Doubt in Interfaces
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:14:01.