This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP SE 5.0 official exam by sun Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP SE 5.0 official exam by sun" Watch "SCJP SE 5.0 official exam by sun" New topic
Author

SCJP SE 5.0 official exam by sun

podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
Here is the link to the Official Test Exam by Sun

http://www.sun.com/training/certification/assessment/index.jsp

I propose to response all the question here, and add a little description/explanation to them ...
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
I will start ..

1. Given the two source files:

1. package com.sun;
2. public class PkgAccess {
3. public static int tiger = 1414;
4. }
And:

1. import static com.sun.PkgAccess.*;
2.
3. public class PkgAccess2 {
4.
5. int x1 = PkgAccess.tiger;
6. int x2 = tiger;
7. int x3 = com.sun.PkgAccess.tiger;
8. int x4 = sun.PkgAccess.tiger;
9. }

Which two are true? (Choose two.)

1 - The PkgAccess2 class compiles.
2 - Compilation fails due to an error on line 5.
3 - Compilation fails due to an error on line 6.
4 - Compilation fails due to an error on line 7.
5 - Compilation fails due to an error on line 8.
6 - The PkgAccess and PkgAccess2 classes both compile.

Answer: 2 and 5 are true.

Explanation : When you say import static com.sun.PkgAccess.*; you are importing every static value of the class PkgAccess, so you can call that value using

com.sun.PkgAccess.tiger // full path to access static "tiger" variable
tiger // use directly the static variable (because we import it !)

you CAN'T SAY

sun.PkgAccess.tiger // because the path is incorrect
PkgAccess.tiger // same as above
[ June 20, 2008: Message edited by: podonga poron ]
podonga poron
Ranch Hand

Joined: May 12, 2008
Posts: 55
2. Given:

1. interface Animal {
2. void eat();
3. }
4.
5. // insert code here
6.
7. public class HouseCat implements Feline {
8. public void eat() { }
9. }
And the following three interface declarations:
interface Feline extends Animal { }
interface Feline extends Animal { void eat(); }
interface Feline extends Animal { void eat() { } }
How many, inserted independently at line 5, will compile?

1 - 0
2 - 1
3 - 2
4 - 3

The Answer is = 3

Explanation: An interface doesn't necessary have to implements methods, so knowing that you can say ..

interface Feline extends Animal { } /* it doesn't implement the Animal methods but is fine since its an interface */

interface Feline extends Animal { void eat(); } /* implements the method eat () */

BUT if you say

interface Feline extends Animal { void eat() { } } /* we have an error here INTERFACE METHODS CAN'T HAVE A BODY, can't have "{}", so it's wrong */
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP SE 5.0 official exam by sun
 
Similar Threads
SUN PROFICIENCY TEST
where are the answers of sun test
Sun practice exam online?
passed today with 85%
Free Mock test