Wednesday, May 30, 2007

SCJP 310-035 Sample Questions (1)

Click here for answer:
Answers of "SCJP 310-035 Sample Questions (1)"


Which of the following are valid declarations? Assume java.util.* is imported.
A. Vector <map> v;
B. Set <string> s;
C. Map <string> m;
D. Map <string,> m;

Which of the following signatures are valid for the main() method entry point of an application?
(Choose all that apply.)
A. public static void main()
B. public static void main(String arg[])
C. public void main(String [] arg)
D. public static void main(String[] args)
E. public static int main(String [] arg)

What results from attempting to compile and run the following code?
1. public class Conditional {
2. public static void main(String args[]) {
3. int x = 4;
4. System.out.println("value is " +
5. ((x > 4) ? 99.99 : 9));
6. }
7. }

A. The output: value is 99.99
B. The output: value is 9
C. The output: value is 9.0
D. A compiler error at line 5

Suppose interface Inty defines five methods. Suppose class Classy declares that it implements Inty but does not provide implementations for any of the five interface methods. Which is/are true?
A. The class will not compile.
B. The class will compile if it is declared public.
C. The class will compile if it is declared abstract.
D. The class may not be instantiated.

When a negative byte is cast to a long, what are the possible values of the result?
A. Positive
B. Zero
C. Negative

You have been given a design document for a veterinary registration system for implementation in Java. It states:
"A pet has an owner, a registration date, and a vaccination- due date. A cat is a pet that has a flag indicating whether it has been neutered, and a textual description of its markings."
Given that the Pet class has already been defined, which of the following fields would be appropriate for inclusion in the Cat class as members?
(Choose all that apply.)

A. Pet thePet;
B. Date registered;
C. Date vaccinationDue;
D. Cat theCat;
E. boolean neutered;
F. String markings;

Which one statement is true concerning the following code?
1. class Greebo extends java.util.Vector
2. implements Runnable {
3. public void run(String message) {
4. System.out.println("in run() method: " +
5. message);
6. }
7. }
9. class GreeboTest {
10. public static void main(String args[]) {
12. Greebo g = new Greebo();
13. Thread t = new Thread(g);
14. t.start();
15. }
16. }

A. There will be a compiler error, because class Greebo does not correctly implement the Runnable interface.
B. There will be a compiler error at line 13, because you cannot pass a parameter to the constructor of a Thread.
C. The code will compile correctly but will crash with an exception at line 13.
D. The code will compile correctly but will crash with an exception at line 14.
E. The code will compile correctly and will execute without throwing any exceptions.

In the following code fragment, after execution of line 1, sbuf references an instance of the StringBuffer class. After execution of line 2, sbuf still references the same instance.
1. StringBuffer sbuf = new StringBuffer("abcde");
2. sbuf.insert(3, "xyz");

A. True
B. False

Suppose you are writing a class that will provide custom serialization. The class implements (not What access mode should the writeObject() method have?
A. public
B. protected
C. default
D. private

EOFException and ObjectStreamException both extend IOException. NotSerializable- Exception extends ObjectStreamException. AWTException does not extend any of these. All are checked exceptions. Suppose class AClass has a method callMe() whose declaration is void callMe() throws ObjectStreamException
Which of the following may appear in a subclass of AClass?
A. void callMe()
B. void callMe() throws IOException
C. void callMe() throws NotSerializableException
D. void callMe() throws ObjectStreamException, AWTException


Latest Posts