Free Cheat-test Samples and Demo Questions Download
Adobe exams Adobe
Apple exams Apple
Avaya exams Avaya
Check Point exams Check Point
Cisco exams Cisco
Citrix exams Citrix
CIW exams CIW
CompTIA exams CompTIA
CWNP exams CWNP
EC-Council exams EC-Council
EMC exams EMC
Exin exams Exin
Fortinet exams Fortinet
GIAC exams GIAC
Hitachi exams Hitachi
HP exams HP
IBM exams IBM
Isaca exams Isaca
ISC exams ISC
ISEB exams ISEB
Juniper exams Juniper
LPI exams LPI
McAfee exams McAfee
Microsoft exams Microsoft
Oracle exams Oracle
PMI exams PMI
Riverbed exams Riverbed
SNIA exams SAP
Sun exams SAS
Symantec exams Symantec
VMware exams VMware
All certification exams

Sun 310-025 Exam - Cheat-Test.com

Free 310-025 Sample Questions:

1. Which two create an instance of an array? (Choose two.)
A. int[] ia = new int[15];
B. float fa = new float[20];
C. char[] ca = "Some String";
D. Object oa = new float[20];
E. int ia[][] = { 4, 5, 6 } { 1, 2, 3 }
Answer: AD

2. Given:
1. public class ArrayTest {
2. public static void main(String[] args) {
3. float f1[], f2[];
4. f1 = new float[10];
5. f2 = f1;
6. System.out.println("f2[0] = " + f2[0]);
7. }
8. }
What is the result?
A. It prints f2[0] = 0.0.
B. It prints f2[0] = NaN.
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an exception at runtime.
Answer: A

3. Given:
1. byte[] array1, array2[];
2. byte array3[][];
3. byte[][] array4;
If each array has been initialized, which statement will cause a compiler error?
A. array2 = array1;
B. array2 = array3;
C. array2 = array4;
D. both A and B
E. both A and C
F. both B and C
Answer: A

4. Given:
1. public abstract class Test {
2. public abstract void methodA();
3.
4. public abstract void methodB()
5. {
6. System.out.println("Hello");
7. }
8. }
Which three changes (made independently) allow the code to compile? (Choose three.)
A. add a method body to methodA
B. replace lines 5 - 7 with a semicolon (";")
C. remove the abstract qualifier from the declaration of Test
D. remove the abstract qualifier from the declaration of methodB
E. remove the abstract qualifier from the declaration of methodA
F. remove methodB in its entirety and change class to interface in line 1
Answer: BDF

5. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplish this objective?
A. public
B. private
C. protected
D. transient
E. No access modifier is qualified.
Answer: C

6. You want a class to have access to members of another class in the same package. Which is the most restrictive access modifier that will accomplish this objective?
A. public
B. private
C. protected
D. transient
E. No access modifier is required.
Answer: E

7. You want to limit access to a method of a public class to members of the same class. Which access modifier accomplishes this objective?
A. public
B. private
C. protected
D. transient
E. No access modifier is required.
Answer: B

8. Which two declarations prevent the overriding of a method? (Choose two.)
A. final void methoda() {}
B. void final methoda() {}
C. static void methoda() {}
D. static final void methoda() {}
E. final abstract void methoda() {}
Answer: AD

9. Which declaration prevents creating a subclass of an outer class?
A. static class FooBar {}
B. private class FooBar {}
C. abstract class FooBar {}
D. final public class FooBar {}
E. final abstract class FooBar {}
Answer: D

10. Given:
1. public class Test {
2. public static void main(String args[]) {
3. class Foo {
4. public int i = 3;
5. }
6. Object o = (Object)new Foo();
7. Foo foo = (Foo)o;
8. System.out.println(foo.i);
9. }
10. }
What is the result?
A. Compilation will fail.
B. Compilation will succeed and the program will print "3".
C. Compilation will succeed but the program will throw a ClassCastException at line 6.
D. Compilation will succeed but the program will throw a ClassCastException at line 7.
Answer: B

11. Given:
1. abstract class AbstractIt {
2. abstract float getFloat();
3. }
4. public class AbstractTest extends AbstractIt {
5. private float f1 = 1.0f;
6. private float getFloat() { return f1; }
7. }
What is the result?
A. Compilation is successful.
B. An error on line 6 causes a runtime failure.
C. An error at line 6 causes compilation to fail.
D. An error at line 2 causes compilation to fail.
Answer: C

12. Given:
1. public class OuterClass {
2. private double d1 = 1.0;
3. // insert code here
4. }
You need to insert an inner class declaration at line 3. Which two inner class declarations are valid? (Choose two.)
A. static class InnerOne {
public double methoda() { return d1; }
}
B. static class InnerOne {
static double methoda() { return d1; }
}
C. private class InnerOne {
public double methoda() { return d1; }
}
D. protected class InnerOne {
static double methoda() { return d1; }
}
E. public abstract class InnerOne {
public abstract double methoda();
}
Answer: CE

13. Click the Exhibit button.
1. public class Test {
2. public int aMethod() {
3. static int i = 0;
4. i++;
5. return i;
6. }
7. public static void main(String args[]) {
8. Test test = new Test();
9. test.aMethod();
10. int j = test.aMethod();
11. System.out.println(j);
12. }
13. }
What is the result?
A. Compilation will fail.
B. Compilation will succeed and the program will print "0".
C. Compilation will succeed and the program will print "1".
D. Compilation will succeed and the program will print "2".
Answer: A

14. Click the Exhibit button.
ClassOne.java:
1. package com.abc.pkg1;
2. public class ClassOne {
3. private char var = 'a';
4. char getVar() { return var; }
5. }
ClassTest.java:
1. package com.abc.pkg2;
2. import com.abc.pkg1.ClassOne;
3. public class ClassTest extends ClassOne {
4. public static void main(String[] args) {
5. char a = new ClassOne().getVar();
6. char b = new ClassTest().getVar();
7. }
8. }
What is the result?
A. Compilation will fail.
B. Compilation succeeds and no exceptions are thrown.
C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
Answer: A

15. Click the Exhibit button.
1. class Super {
2. public int i = 0;
3.
4. public Super(String text) {
5. i = 1;
6. }
7. }
8.
9. public class Sub extends Super {
10. public Sub(String text) {
11. i = 2;
12. }
13.
14. public static void main(String args[]) {
15. Sub sub = new Sub("Hello");
16. System.out.println(sub.i);
17. }
18. }
What is the result?
A. Compilation will fail.
B. Compilation will succeed and the program will print "0".
C. Compilation will succeed and the program will print "1".
D. Compilation will succeed and the program will print "2".
Answer: A

16. Which two statements are true regarding the creation of a default constructor? (Choose two.)
A. The default constructor initializes method variables.
B. The default constructor invokes the no-parameter constructor of the superclass.
C. The default constructor initializes the instance variables declared in the class.
D. If a class lacks a no-parameter constructor, but has other constructors, the compiler creates a default constructor.
E. The compiler creates a default constructor only when there are no other constructors for the class.
Answer: BE

17. Which two statements are true regarding the creation of a default constructor? (Choose two.)
A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create a default constructor.
Answer: CE

18. Given:
1. public class ReturnIt {
2. returnType methodA(byte x, double y) {
3. return (long)x / y * 2;
4. }
5. }
What is the valid returnType for methodA in line 2?
A. int
B. byte
C. long
D. short
E. float
F. double
Answer: F

19. Given:
1. public class ReturnIt {
2. returnType methodA(byte x, double y) {
3. return (short)x / y * 2;
4. }
5. }
What is the valid returnType for methodA in line 2?
A. int
B. byte
C. long
D. short
E. float
F. double
Answer: F

20. Given:
1. class Super {
2. public float getNum() { return 3.0f; }
3. }
4.
5. public class Sub extends Super {
6.
7. }
Which method, placed at line 6, will cause a compiler error?
A. public float getNum() { return 4.0f; }
B. public double getNum() { return 4.0d; }
C. public float getNum(double d) { return 4.0f; }
D. public double getNum(float d) { return 4.0d; }
Answer: B

21. Given:
1. class Super {
2. public float getNum() { return 3.0f; }
3. }
4.
5. public class Sub extends Super {
6.
7. }
Which method, placed at line 6, will cause a compiler error?
A. public float getNum() { return 4.0f; }
B. public void getNum() { }
C. public void getNum(double d) { }
D. public double getNum(float d) { return 4.0d; }
Answer: B

22. Click the Exhibit button.
1. class Super {
2. public int getLength() { return 4; }
3. }
4.
5. public class Sub extends Super {
6. public long getLength() { return 5; }
7.
8. public static void main(String[] args) {
9. Super sooper = new Super();
10. Sub sub = new Sub();
11. System.out.println(
12. sooper.getLength() + "," + sub.getLength() );
13. }
14. }
What is the output?
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. The code will not compile.
Answer: E

23. Click the Exhibit button.
1. class Super {
2. public Integer getLength() { return new Integer(4); }
3. }
4.
5. public class Sub extends Super {
6. public Long getLength() { return new Long(5); }
7.
8. public static void main(String[] args) {
9. Super sooper = new Super();
10. Sub sub = new Sub();
11. System.out.println(
12. sooper.getLength().toString() + "," +
13. sub.getLength().toString() );
14. }
15. }
What is the output?
A. 4,4
B. 4,5
C. 5,4
D. 5,5
E. The code will not compile.
Answer: E

24. Given:
1. switch(i) {
2. default:
3. System.out.println("Hello");
4. }
What are the two acceptable types for the variable i? (Choose two.)
A. char
B. byte
C. float
D. double
E. Object
Answer: AB

25. Given:
1. switch(i) {
2. default:
3. System.out.println("Hello");
4. }
What is the acceptable type for the variable i?
A. byte
B. long
C. float
D. double
E. Object
F. A and B
G. C and D
Answer: A

26. Given:
1. public class IfTest {
2. public static void main(String[] args) {
3. int x = 3;
4. int y = 1;
5. if (x = y)
6. System.out.println("Not equal");
7. else
8. System.out.println("Equal");
9. }
10. }
What is the result?
A. The output is "Equal".
B. The output is "Not equal".
C. An error at line 5 causes compilation to fail.
D. The program executes but does not print a message.
Answer: C

27. Click the Exhibit button.
1. public class SwitchTest {
2. public static void main(String[] args) {
3. System.out.println("value = " + switchIt(4));
4. }
5. public static int switchIt(int x) {
6. int j = 1;
7. switch (x) {
8. case 1: j++;
9. case 2: j++;
10. case 3: j++;
11. case 4: j++;
12. case 5: j++;
13. default: j++;
14. }
15. return j + x;
16. }
17. }
What is the output from line 3?
A. value = 3
B. value = 4
C. value = 5
D. value = 6
E. value = 7
F. value = 8
Answer: F

28. Click the Exhibit button.
1. int i = 1, j = 0;
2.
3. switch(i) {
4. case 2:
5. j += 6;
6.
7. case 4:
8. j += 1;
9.
10. default:
11. j += 2;
12.
13. case 0:
14. j += 4;
15. }
16.
What is the value of j at line 16?
A. 0
B. 1
C. 2
D. 4
E. 6
Answer: E

29. Click the Exhibit button.
1. public class Test {
2. public static void main(String args[]) {
3. int i = 0;
4. while(1) {
5. if(i == 4) {
6. break;
7. }
8. ++i;
9. }
10.
11. }
12. }
What is the value of i at line 10?
A. 0
B. 3
C. 4
D. 5
E. The code will not compile.
Answer: E

30. Given:
3. int i = 1, j = 10;
4. do {
5. if (i > j)
6. break;
7. j--;
8. }while (++i < 5);
After execution, what are the values for i and j?
A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6
Answer: D


© 2014 Cheat-Test.com, All Rights Reserved