Looking for Real Exam Questions for IT Certification Exams!

We Guarantee you can pass any IT certification exam at your first attempt with just 10-12 hours study of our guides. Our study guides contain actual exam questions, you will get word to word same on your actual test; accurate answers with detailed explanation verified by experts and all graphics and drag-n-drop exhibits shown just as on the real test. To test the quality of our guides, you can download the one-third portion of any guide from http://www.certificationking.com absolutely free. Besides, we also offer complete version of following exams absolutely free. You can start your certification from these free guides and if you are satisfied you can buy the rest
♦ Microsoft: 70-214, 70-290, 70-360, 70-431, 70-536, MB2-421 ♦ CCNP: 642-801 ♦ CCIP: 642-611 ♦ CCSP/ VPN & Security: 642-501 ♦ CCVP/ IP Comm/ Specialist: 642-432 ♦ Oracle: 1Z0-007, 1Z0-001 ♦ CIW: 1D0-510 ♦ Novell: 50-632 ♦ Citrix: 1Y0-223 ♦ Lotus: 190-510 ♦ HP: HP0-714 ♦ APPLE: 9L0-401 ♦ BEA: 0B0-101 ♦ Symantec: 250-501 ♦ Exam Express: EE0-011 ♦ Juniper: JN0-120 ..more

For pricing and placing order, please visit http://certificationking.com/order.html We accept all major credit cards through www.paypal.com For other payment options and any further query, feel free to mail us at info@certificationking.com

Exam: 310-025 Title: Sun Java Certified Programmer
# QUESTION 1: Given: 1 public class test ( 2 public static void main (String args[]) { 3 int i = 0xFFFFFFF1; 4 int j = ~i; 5 6 } 7 ) What is the decimal value of j at line 5?

A. 0 B. 1 C. 14 D. -15 E. An error at line 3 causes compilation to fail. F. An error at line 4 causes compilation to fail. Answer: C

# QUESTION 2: Given: Integer i = new Integer (42); Long 1 = new Long (42); Double d = new Double (42.0); Which two expressions evaluate to True? (Choose Two) A. (i ==1) B. (i == d) C. (d == 1) D. (i.equals (d)) E. (d.equals (i)) F. (i.equals (42)) Answer: D, E

12 ) 13 ) What is the result? A. 11 system. The program prints "8" D. The program prints "0" B. 7 ) 8 9 public static void main (String args[] } ( 10 methodA (0).printIn(j). 3 4 private static boolean methodB(int k) ( 5 j += k.out. 6 b = i < 10 || methodB (8).# QUESTION 3: Exhibit : 1 public class test ( 2 private static int j = 0. The code does not complete. 1 ) 2 3 public static void methodA(int i) { 4 boolean b: 5 b = i < 10 | methodB (4).printIn (6 ^ 3). 6 return true. The program prints "4" C.out. 4 ) 5 ) . The program prints "12" E. Answer: B # QUESTION 4: Given 1 Public class test ( 2 Public static void main (String args[]) ( 3 System.

) . F. 11 ) 12 } What is the result? A. The code compiles and prints "A. E.B". B.B". 10 y = x. 7 ) 8 static void operate (StringBuffer x. D. The code compiles and prints "AB.b). 'i').replace ('j' . The code compiles and prints "A. 4 StringBuffer b = new StringBuffer ("B"). 5 operate (a. 6 system.AB".printIn{a + ". The code does not compile because "+" cannot be overloaded for StringBuffer.B".A"." +b}. The code compiles and prints "AB.out. Answer: D # QUESTION 6: Exhibit: 1 Public class test ( 2 3 4 Public static void stringReplace (String text) ( Text = text. The code compiles and prints "B.append {y}. StringBuffer y) { 9 x.What is the output? Answer: 5 # QUESTION 5: Given: 1 public class Foo { 2 public static void main (String [] args) { 3 StringBuffer a = new StringBuffer ("A"). C.

intValue ( ). 12 } 13 ) . 6 } 7 8 public static void main (String args [ ] ) { 9 Integer i = new Integer (0). 5 i = new Integer (val). StringBuffer text BufferString = new StringBuffer ("java"). } 19 ) What is the output? Answer: JAVAJAVA # QUESTION 7: Exhibit: 1 public class test { 2 public static void add3 (Integer i) } 3 int val = i.out.5 6 7 8 9 10 11 12 13 14 15 16 17 18 public static void bufferReplace (StringBuffer text) ( text = text. 10 add3 (i). System. 4 val += 3.printIn (i. BufferReplace (textBuffer).printLn (textString + textBuffer). 11 system. stringReplace (textString).intValue ( ) ).append ("C") ) public static void main (String args[]} ( String textString = new String ("java").out.

Public Object ConstOver (int x. Public void ConstOver (byte x. byte x) { } D. C. Compilation will fail. The program prints "3". D. byte y. ConstOver ( ) { } B. B. float c. int z) { } E. int b. int y. The program prints "0".What is the result? A. Answer: B # QUESTION 8: Given: 1 public class ConstOver { 2 public ConstOver (int x. float c) { } . int z) { 3 } 4 } Which two overload the ConstOver constructor? (Choose Two) A. int y. Private void setVar (int a. Protected int ConstOver ( ) { } C. Private ConstOver (int z. int y. byte z) { } Answer: A. float c) { 3 } 4 } Which two overload the setVar method? (Choose Two) A. Protected void setVar (int a. int b) { } B. int b. C # QUESTION 9: Given: 1 public class MethodOver { 2 public void setVar (int a. Compilation will succeed but an exception will be thrown at line 3.

Public float getVar (float f ) { return f.) E.) 4 } 5 class Subclass extends BaseClass ( 6 private float x = 2. float c) (return c.} B. Protected float setVar (int a.) Answer: A. float c) (return a. public class Species { } public class Animal (private Species species. Public int setVar (int a.} E.0f . Public int setVar (int a. public interface Person { } public class Employee extends Person { } B.} D.} C. Float getVar ( ) { return x. D # QUESTION 11: Which two demonstrate an "is a" relationship? (Choose Two) A. public interface Shape { } public class Employee extends Shape { } C. int b.C.0f. int b) (return a. float c. Public float getVar ( ) { return x. public interface Color { } public class Employee extends Color { } D. Float double getVar ( ) { return x.) . 7 //insert code here 8 ) Which two are valid examples of method overriding? (Choose Two) A. C # QUESTION 10: Given: 1 class BaseClass { 2 Private float x = 1. int b. 3 protected float getVar ( ) ( return x.) D. Public float getVar ( ) { return x.} Answer: B.

C. interface Component { } Class Container implements Component ( Private Component[ ] children. An instance of the inner class can only be constructed from within the outer class. An instance of the Inner class can be constructed with "new Outer. Construction of an instance of a static inner class requires an instance of the enclosing outer class.E. E # QUESTION 12: Which statement is true? A. B. An anonymous inner class can implement multiple interfaces. C. an instance of the inner class can be constructed with "new inner()" Answer: A # QUESTION 14: Exhibit: 1 public class enclosingone ( 2 public class insideone{} 3 ) 4 public class inertest( . E. An instance of the inner class cannot be constructed outside of package foo. An anonymous inner class can access final variables in any enclosing scope. D. An anonymous inner class may be declared as final.Inner ()" B. D. 2 3 public class Outer ( 4 public static class Inner ( 5 ) 6 ) Which statement is true? A. From within the package bar. ) Answer: D. An anonymous inner class can be declared as private. Answer: D # QUESTION 13: Given: 1 package foo.

What is the result? A. B. D. An error at line 2 causes compilation to fail. //insert code here ) ) Which statement at line 7 constructs an instance of the inner class? A.new InsideOn(). 12. InsideOnew ei= eo. Answer: A .) 13. E.InsideOne ei = eo. 9 i= Cert.new InsideOne().k.new InsideOne().5 6 7 8 9 public static void main (string[]args)( enclosingone eo= new enclosingone (). An error at line 11 causes compilation to fail. An error at line 10 causes compilation to fail. EnclosingOne. B. 3 ] 4 5 public class test implements Foo ( 6 public static void main(String args[]) ( 7 int i. Answer: D # QUESTION 15: Exhibit: 1 interface foo { 2 int k = 0.) 14. C. C.k. 10. An error at line 9 causes compilation to fail. D. Eo.k.i= Foo. 11. 8 Cert cert = new test (). InsideOne ei = EnclosingOne.InsideOne ei = eo. Compilation succeeds.i= Cert.new InsideOne().

D.io. C # QUESTION 18: Which three are valid declarations of a float? (Choose Three) A.03d.io. Include java. Import java. 6 out. Float foo = 2. D. F. Include java.PrintWriter.OutputStreamWriter. true. Default D.out).PrintWriter.io. Implement Answer: B.printIn("Hello"). Float foo = 0x0123. Import java. Import C. Float foo = 42e1. B.io. Run B.OutputStreamWriter.# QUESTION 16: Given: 1 //point X 2 public class foo ( 3 public static void main (String[]args) throws Exception { 4 printWriter out = new PrintWriter (new 5 java.0. Answer: A.io. F . C. E. Answer: A # QUESTION 17: Which two statements are reserved words in Java? (Choose Two) A. 7 } 8 ) Which statement at PointX on line 1 allows this code to compile and run? A.02f. Float foo = -1. No statement is needed. E.outputStreamWriter (System. D. B. Float foo = 3. Float foo = 1. C.

3 boolean foo= test [index].# QUESTION 19: Given: 1 int index = 1. 4 string foo = args [2]. An exception is thrown. Foo has the value of 0. G. Baz has the value of "red" D. Baz has the value of "blue" E. Baz has the value of null C. The code will not compile. Foo has the value of null. B. Baz has the value of "" B. E. 5 string foo = args [3]. What is the result? A. Foo has the value of false. The code does not compile. Answer: G . C. 6 } 7 } And command line invocation: Java Test red green blue What is the result? A. Bax has the value of "green" F. F. Foo has the value of true. D. Answer: D # QUESTION 20: Given: 1 public class test( 2 public static void main(string[]args){ 3 string foo = args [1]. The program throws an exception. 2 boolean[] test = new Boolean[3].

int bar = foo [index]. B. Protected void methoda (double d1){} Answer: D . Baz has the value of 2 D. Static void methoda (double d1) {} C. C.printIn ("s=" + s). 4 system.# QUESTION 21: Given: 1 int index = 1. Baz has the value of 0 B. but a NullPointerException is thrown when toString is called. B. Answer: B # QUESTION 22: Given: 1 public class foo { 2 public static void main (String[]args) { 3 String s. D. Public double methoda().int baz = bar + index. 11. Answer: C # QUESTION 23: Which will declare a method that forces a subclass to implement it? A. The code does not compile because string s is not initialized. The code does not compile because string s cannot be referenced. D. The code compiles and "s=" is printed. 2 int [] foo = new int [3]. The code will not compile. The code compiles. What is the result? A. The code compiles and "s=null" is printed. E. E. 10. Baz has the value of 1 C. Abstract public void methoda(). 5 } 6 } What is the result? A. E. Public native double methoda().out. An exception is thrown.

. 6 private float getFloat () {return f1. 3 ) 4 public class AbstractTest extends AbstractIt { 5 private float f1= 1. D. i++. C. Compilation is successful.} 7 } What is the result? A. B. Protected D. Transient E. Private C. An error at line 2 causes compilation to fail. Answer: C # QUESTION 26: Exhibit: 1 public class test( 2 3 4 public int aMethod()[ static int i=0. An error on line 6 causes a runtime failure. Which is the most restrictive access modifier that will accomplish this objective? A. No access modifier is qualified Answer: C # QUESTION 25: Given: 1 abstract class abstrctIt { 2 abstract float getFloat (). An error at line 6 causes compilation to fail.0f.# QUESTION 24: You want subclasses in any package to have access to members of a superclass. Public B.

will cause a compiler error? A.5 6 7 8 return I.printIn(j). 10. Public void getNum (double d) { } D. 12.0f. placed at line 6.int j = test.0f. Compilation will succeed and the program will print "2" Answer: D # QUESTION 27: Given: 1 class super { 2 public float getNum() {return 3.aMethod(). Public void getNum () { } C.} What is the result? A.out.System. 9 test. ) public static void main (String args[]){ test test = new test(). Compilation will succeed and the program will print "1" D.} 3 ) 4 5 public class Sub extends Super { 6 7 ) Which method. Compilation will succeed and the program will print "0" C. } .aMethod(). Public float getNum() {return 4. } B. Public double getNum (float d) {retrun 4. B.] 13. Compilation will fail.0f. 11.

D. Array2 = array4. Both A and C F. Both B and C Answer: F # QUESTION 30: Exhibit: 1 class super ( 2 public int I = 0. Final public class FooBar{} E. which statement will cause a compiler error? A. 3 byte[][] array4. B. Static class FooBar{} B.Answer: B # QUESTION 28: Which declaration prevents creating a subclass of an outer class? A. Final abstract class FooBar{} Answer: D # QUESTION 29: Given: 1 byte [] arry1. Private class FooBar{} C. 3 4 public super (string text) ( 5 I=1 6 ) 7 ) . If each array has been initialized. 2 byte array3 [][]. Abstract public class FooBar{} D. C. array2[]. Array2 = array3. Both A and B E. Array2 = array1.

PrintIn(sub. Short . Compilation will succeed and the program will print "0" C. 16 system. double y) ( return (short) x/y * 2. Int B. ) 5 ) What is the valid returnType for methodA in line 2? A.i).8 9 public class sub extends super ( 10 public sub (string text) ( 11 i= 2 12 ) 13 14 public static void main (straing args[]) ( 15 sub sub = new sub ("Hello"). Compilation will succeed and the program will print "2" Answer: A # QUESTION 31: Given: 1 public class returnIt ( 2 3 4 returnType methodA(byte x.out. Byte C. B. Long D. 17 ) 18 ) What is the result? A. Compilation will fail. Compilation will succeed and the program will print "1" D.

which method allows you to identify the affected component? A. Public void mouseMoved(MouseEvent) B. Public void mouseMoved(MouseMotionEvent) D. 14 Add(p1).add(b1). Public boolean MouseMoved(MouseMotionEvent) E. B. 12 13 Panel p1 = new panel(). Double Answer: F # QUESTION 32: Given the ActionEvent. D.awt*. GetTarget. Float F. Answer: C # QUESTION 33: Which is a method of the MouseMotionListener interface? A. GetComponent. .setVisible(true). 6 X.pack(). Public boolean mouseMoved(MouseEvent) C. E. GetTargetComponent. 2 3 public class X extends Frame ( 4 public static void main(string []args) ( 5 X x = new X (). 16 P1.E. C. GetClass. 15 Button b1= new Button ("One"). 8 ) 9 10 public X () ( 11 setlayout (new GridLayout (2.2)). Public boolean mouseMoved(MouseMotionEvent) Answer: A # QUESTION 34: Exhibit: 1 import java. GetSource. 7 x.

D. GridBagLayout.add(b2). String name= File. FlowLayout. All the buttons change width if the Frame width is resized.txt")).txt")). 25 26 Button b4= new Button ("Four"). BorderLayout.txt").getParentName(). 19 Add(p2). 20 Button b2= new Button ("Two"). String name = (new File("file. Which layout manager can the panel use to ensure that the TextArea absorbs all of the free vertical space when the panel is resized? A. CardLayout. C. Answer: C. String name= (new File("file. Answer: E # QUESTION 36: Which gets the name of the parent directory file "file. 21 P2. String name= (new File("file. C. a label directly below it.getParentFile().17 18 Panel p2 = new panel(). 27 add(b4). All the buttons change height if the frame height is resized. GridLayout. 22 23 Button b3= new Button ("Three"). D. D.getParentName("file. If the three components are added directly to the panel.txt"? A. The size of the button labeled "One" is constant even if the Frame is resized. 24 add(b3).txt")).getParent(). B. C. 28 ) 29 ) Which two statements are true? (Choose Two) A. B. B. Both width and height of the button labeled "Three" might change if the Frame is resized. D # QUESTION 35: You are assigned the task of building a panel containing a TextArea at the top. . and a button directly below the label. E.

BufferedOutputStream.txt")).getParentDir().txt")). New dataOutputStream(new FileOutputStream("out.getName().txt"? A. 4 } 5 catch (IOException) {} What is the result? A. F. Java.OutputStreamWriter. B. The code runs and no change is made to the file. New dataOutputStream(new FileWriter("out. true).txt"). C. Java.io.EncodeOutputStream.txt" exists on the file system and contsins ASCII text. E. Given: 1 try { 2 File f = new File("file. Answer: F # QUESTION 40: What writes the text "<end>" to the end of the file "file. DataOutputStream out = new . New dataOutputStream(new file("out. Java. Answer: B # QUESTION 38: The file "file.io. New dataOutputStream(new writer("out. An exception is thrown because the file is not closed. Answer: B # QUESTION 37: Which can be used to encode charS for output? A. E. D. OutputStream out= new FileOutputStream ("file.EncodeWriter. D.txt")). Answer: A # QUESTION 39: Which constructs a DataOutputStream? A.txt")).OutputStream.txt")). Java. New dataOutputStream(new OutputStream("out. B. E.writeBytes ("<end>/n"). New dataOutputStream("out. C.txt"). 3 OutputStream out = new FileOutputStream(f. OutputStream os= new FileOutputStream ("file.txt"). Java.io. C.io. Directory dir=(new File ("file. The code runs and deletes the file from the file system.E. The code does not compile. String name= dir. B.txt")). true). Out. B.txt". D. The code runs and sets the length of the file to 0.io.

return oa[0]. Just after line 7 (that is. } 9 } When is the float object created in line 3. D. Just after line 5 B. DataOutputStream out = new DataOutputStream(os). as the method returns) D.writeBytes ("<end>/n"). 3 foo. Just after line 6 C. oa[0]= o. out.DataOutputStream(os). o = null. OutputStream os= new OutputStream ("file.txt"). Answer: D # QUESTION 42: Given: 1 string foo = "ABCDE". C. object [] oa = new object [1]. out. DataOutputStream out = new DataOutputStream(os).14F).txt". 2 foo. Never in this method. out. . true). eligible for garbage collection? A.concat("XYZ").writeBytes ("<end>/n").writeBytes ("<end>/n"). OutputStream os= new FileOutputStream ("file. Answer: B # QUESTION 41: Given: 1 public class X ( 2 3 4 5 6 7 8 public object m () { object o = new float (3.substring(3).

B.util. E.Map. Answer: ABCDE # QUESTION 43: Which method is an appropriate way to determine the cosine of 42 degrees? A. The elements in the collection are guaranteed to be unique. Java. C.util. Java. The elements in the collections are guaranteed to be synchronized.HashSet? A.util. Double d = Math.util. Double d = Math. E.toRadians(42)). Answer: D # QUESTION 45: Which statement is true for the class java. F. Java. Java. Answer: C # QUESTION 44: You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. The elements in the collection are accessed using a unique key. E.util.Collection. 7 else .cos(42).Set. The collection is guaranteed to be immutable.util.cos(Math. B.toDegrees(42)). Java.cosine(42).toRadians(42)).printIn("Not equal").cosine(Math. 4 int y = 1. Answer: C # QUESTION 46: Given: 1 public class IfTest ( 2 public static void main(string[]args) { 3 int x = 3. C.cos(Math. D. Double d = Math.util. Java. The elements in the collection are ordered.StoredMap.StoredSet. C. D. B. Double d = Math.out.List.4 Type the value of foo at line 6. Double d = Math. 5 if (x = y) 6 system. Which interface provides that capability? A. D.

) ) 12 ) What is the value of i at line 10? A. 9 } 10 ) What is the result? A.out.printIn("Equal"). The program executes but does not print a message. 0 . ) ++i. D. The output in "Not Equal" C. The output is "Equal" B.8 system. while (i) { if (i==4) { break. An error at line 5 causes compilation to fall. Answer: C # QUESTION 47: Exhibit: 1 public class test ( 2 3 4 5 6 7 8 9 10 11 public static void main(string args[]) { int 1= 0.

j= 10 . what are the values for I and j? A. i = 5 and j= 6 E.B. i = 6 and j= 6 Answer: D # QUESTION 49: Given: 1 switch (i) { 2 3 default: System. 5 E.printIn("Hello"). 3 C. Answer: E # QUESTION 48: Given: 1 int i= 1. 4 D. 4 ) while (i<5).out. 2 do ( 3 if (i++> --j) continue. 4 ) What are the two acceptable types for the variable i? (Choose Two) A. i = 5 and j= 5 C. The code will not compile. After execution. i = 6 and j= 4 D. i = 6 and j= 5 B. Char .

10 ) 11 ) 12 public void methodA () { 13 throw new IOException ().} 5 } 6 ) What is the result? A.out.printIn("Finally"). The program runs and prints "Finally" C. Float D. 2 public class ExceptionTest( 3 public static void main (String[]args) 4 try ( 5 methodA().IOException. D. B.out. The code compiles. The code will not compile because the catch block is missing. B # QUESTION 50: Given: 1 public class foo { 2 public static void main (string[]args) 3 try {return.io.out. 8 ) catch (Exception e) ( 9 system.} 4 finally {system. Byte C.printIn("Caught IOException"). but an exception is thrown at runtime. Object Answer: A.printIn("Caught Exception"). Double E. The program runs and prints nothing. 14 ) .B. 6 ) catch (IOException e) ( 7 system. Answer: B # QUESTION 51: Exhibit: 1 import java.

Sign up to vote on this title
UsefulNot useful