Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question from Biran's book

 
Li Wenfeng
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a question about abstract class.

Given:
1. class A{
2. abstract int getNum();
3. }
And the following:
4.
5. public static int pi=3;
6. int getNum(){
7. return 5;
8. }
9. }
The second file can be compiled successfully by inserting a line of code on line 4. Which of the following lines will allow compilation to succeed? (Choose all that apply.)
A. class B extends A{
B. abstract class B extends A{
C. final abstract class B extends A{
D. final class B extends A{
E. abstract class B{

My answer is E, but Biran gives the answer of A,B,D,and E. If the keyword abstract was added in front of line 1, then I think his answer is right.
However,in the preceding question, class A will not be compiled at all! Biran made another mistake, so I will compile and run the sample questions about which I am not sure to really grasp every objective!
[ August 31, 2002: Message edited by: Li Wenfeng ]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A class with an abstract method must have the keyword abstract in its class definition. You are correct that the question contains an error.
 
Li Wenfeng
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,all
who are using Biran's scjp book: 《Sun Certified Programmer for Java 2 Study Guide,Second Edition(Exam:310-025)》? I found quite a lot of errors in his book? Anyway, he indeed give the details of conceptes for the picky SCJP2 exam. But he did not provide feedback forms, or errata page!
[ August 31, 2002: Message edited by: Li Wenfeng ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic