• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K & B 1.5 Chapter 8 self Test Q.12

 
Andrew Danieli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've been lurking for a while, but thought I'd get some help with a question where the code doesn't seem to match the answer? My first look at C8.Q12 was to choose answer A, which is what the book said was correct, however when I typed the code in (and alternately cut-n-pasted from the pdf), I get a compilation error on "AbstractTest.Bar f = t.new Bar () {..."

Error(46,36): class AbstractTest.Bar is abstract; cannot be instantiated

I couldn't see anything in the Errata so I thought I'd check with the authors.

I'm starting to panic a bit as my exam is on Friday, and I'm worried that I haven't prepared enough (read the book a several times, done all the Sun mock exams twice + the K & B self tests & the examulator freebie exam).

Thanks

Andrew
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew! Welcome to javaranch.

Well the question is question no. 6 in my SCJP 6 book. The pdf doesn't let me to copy paste the code (I don't how it let you CUT paste the code ). Other than that I think the code must run fine. Just post the complete code here.
 
Andrew Danieli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the welcome. Here's the code from my source file.



I'm using JDeveloper 10.1.3.3 and the error I get as mentioned above is:-

Error(46,36): class AbstractTest.Bar is abstract; cannot be instantiated
 
Ankit Garg
Sheriff
Posts: 9509
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew the code runs fine on my jdk 1.6...
 
Andrew Danieli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same here. I've got the Sun JDK 1.6 on my PC as well as the Oracle 1.5 JDK inside JDeveloper. Just tried and it compiled quite happily in 1.6. Something odd with Oracle.

As I can't compile the code in the real exam, I'll have to go with my gut instinct, for some of the answers.

Thanks for your help.

Andrew
 
Vikas Govindswamy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Even i am also preparing for SCJP1.5
I ran the same code (in Eclipse3.4 with Java1.5 installed) that you pasted above, and it is running fine and giving the output 57 22.

-Vikas
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FWIW -

When Sun created the real exam, all of the questions were compiled and tested from the command line, and when we wrote the book we also used the command line exclusively.

Bottom line - we STRONGLY recommend NOT using IDEs to study for the exam.

Bert
 
Andrew Danieli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bert,

Thanks for the advice. This is the only problem I've had so far. Given I've only got a day left before the exam, its a little late to change tack.

I'll let everyone know how I get on.

Regards

Andrew
 
Andrew Danieli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I thought I should let you know that I passed. Thanks go to Kathy and Bert for a 1st class book, especially the bit about exam techniques. Its going to be my new java reference bible.

Regards

Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic