SCJP认证考试历年真题.pdf
SCJP认证考试历年真题这都是考试原题,有心人可以收集收集,会让你收益匪浅!因为这一套较多,所以我分 将他罗列出来!310-025Leading the way in IT testing and certification tools,Question No:1Given:1.public class test(2.publie static void main(String args)3.int i=OxFFFFFFFl;4.int j=i;5.6.)7.)What is the decimal value of j at line 5?A.0B.1C.14D.-15E.An error at line 3 causes compilation to fail.F.An error at line 4 causes compilation to fail.Answer:DQuestion No:2Given: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,EQuestion No:3E xhibit:1.public class test(2.private static int j=0;3.4.private static boolean methodB(int k)(5.j+=k;6.return true;6.)7.8.public static void methodA(int i)9.boolean b:10.b=i 10 methodB(4);11.b=i 10 methodB(8);12.)13.14.public static void main(String args (15.methodA(0);16.system,out.println(j);17.)18.)What is the result?A.The program prints 0”B.The program prints 4”C.The program prints 8”D.The program prints 12”E.The code does not complete.Answer:BQuestion No:4Given1.Public class test(2.Public static void main(String args)(3.System.out.printin(6 3);4.)5.)What is the output?Answer:5Question No:5Given:1.publie class Foo 2.public static void main(String 口 args)3.StringBuffer a=new StringBuffer(A”);4.StringBuffer b=new StringBuffer(B );5.operate(a,b);6.system.out.printina+“,”+b;7.)8.static void operate(StringBuffer x,StringBuffery)9.x.append y;10.y=x;1 1.)12.Wha t is the resul t?A.The code compil es a nd prints“A,B”.B.The code compil es a nd prints“A,A”.C.The code compil es a nd prints“B,B”.D.The code compil es a nd prints“AB,B”.E.The code compil es a nd prints“AB,AB”.F.The code does not compil e beca use +ca nnot beoverl oa ded for String Buffer.Answer:DQuestion No:6Exhibit:1.Publ ic cl a ss test(2.Publ ic sta tic void string Repl a ce(String t e x t)(3.Text=text,repl a ce(,j ,,i);4.)5.6.publ ic sta tic void bufferRepl a ce(String Buffer text)7.text=text,a ppend(C)8.)9.10.public static void main(String args(11.String textString=new String(java”);12.StringBuffer text BufferString=new StringBuffer(“java”);13.14.stringReplace(textString);15.BufferReplace(textBuffer);16.17.System.out.printin(textString+textBuffer);18.19.)What is the output?Answer:javajavaCQuestion No:7E xhibit:1.public class test 2.public static void add3(Integer i)3.int val=i.intValue();4.val+=3;5.i=new Integer(val);6.)7.8.public static void main(String args )9.Integer i=new Integer(0);10.add3(i);11.system,out.printin(i.intValue();12.1 3.)What is the result?A.Compilation will fail.B.The program prints 0”.C.The program prints 3”.D.Compilation will succeed but an exception will bethrown at line 3.Answer:BQuestion No:8Given:1.public class ConstOver 2.public ConstOver(int x,int y,int z)3.)4.)Which two overload the ConstOver constructor?(ChooseTwo)A.ConstOver()B.Protected int ConstOver()C.Private ConstOver(int z,int y,byte x)D.Public Object ConstOver(int x,int y,int z)E.Public void ConstOver(byte x,byte y,byte z)Answer:A,CQuestion No:9Given:1.public class MethodOver 2.public void setVar(int a,int b,float c)3.)4.)Which two overload the setVar method?(Choose Two)A.Private void setVar(int a,float c,int b)B.Protected void setVar(int a,int b,float c)C.Public int setVar(int a,float c,int b)(returna;)D.Public int setVar(int a,int b,float c)(returna;)E.Protected float setVar(int a,int b,float c)(return c;)Answer:A,CQuestion No:10Given:1.class BaseClass 2.Private float x=1.Of;3.protected float getVar()(return x;)4.)5.class Subclass extends BaseClass(6.private float x=2.Of;7./in sert code here8.)Which two are valid examples of method overriding?(Choose Two)A.Float getVar()return x;B.Public float getVar()return x;C.Float double getVar()return x;D.Public float getVar()return x;E.Public float getVar(float f)return f;Answer:B,DQuestion No:11Which two demonstrate an is a”relationship?(ChooseTwo)A.public interface Person public class Employee extends Person B.public interface Shape public class Employee extends Shape C.public interface Color public class Employee extends Color D.public class Species public class Animal(private Species species;)E.interface Component Class Container implements Component(Private Component children;)Answer:D,EQuestion No:12Which statement is true?A.An anonymous inner class may be declared as final.B.An anonymous inner class can be declared as private.C.An anonymous inner class can implement multipleinterfaces.D.An anonymous inner class can access final variablesin any enclosing scope.E.Construction of an instance of a static inner classrequires an instance of the enclosing outer class.Answer:DQuestion No 13Given:1.package foo;2.3.public class Outer(4.public static class Inner(5.)6.)Which statement is true?A.An instance of the Inner class can be constructedwith“new Outer.Inner()”B.An instance of the inner class cannot be constructedoutside of package foo.C.An instance of the inner class can only beconstructed from within the outer class.D.From within the package bar,an instance of the innerclass can be constructed with“new inner。Answer:AQuestion No 14Exhibit:1.public class enclosingone(2.public class insideone 3.)4.public class inertest(5.publie static void main(stringargs)(6.enclosingone eo=new enclosingone();7./insert code here8.)9.)Which statement at line 7 constructs an instance of theinner class?A.InsideOnew ei=eo.new InsideOn();B.Eo.InsideOne ei=eo.new InsideOne();C.InsideOne ei=EnclosingOne.new InsideOne();D.EnclosingOne.InsideOne ei=eo.new InsideOne();Answer:DQuestion No 15Exhibit:1.interface foo 2.int k=0;3.4.5.public class test implements Foo(6.public static void main(String args)(7.int i;8.Test test=new test();9.i=test,k;10.i=Test,k;11.i=Foo.k;12.)13.)14.What is the result?A.Compilation succeeds.B.A n error at line 2 causes compilation to fail.C.An error at line 9 causes compilation to fail.D.An error at line 10 causes compilation to fail.E.A n error at line 11 causes compilation to fail.Answer:AQuestion No 16Given:1./point X2.public class foo(3.public static void main(Stringargs)throwsException 4.printWriter out=new PrintWriter(new5.java.io.outputStreamWriter(System,out),true;6.out.printin(Hello);7.)8.)Which statement at PointX on line 1 allows this codeto compile and run?A.Import java.io.PrintWriter;B.Include java.io.PrintWriter;C.Import java.io.OutputStreamWriter;D.Include java.io.OutputStreamWriter;E.No statement is needed.Answer:AQuestion No 17Which two statements are reserved words in Java?(Choose Two)A.RunB.ImportC.DefaultD.ImplementAnswer:B,CQuestion No 18Which three a re va l id decl a ra tions of a fl oa t?(ChooseThree)B.C.D.E.F.A.Fl oa t foo=-1;Fl oa t foo=1.0;Fl oa t foo=42el;Fl oa t foo=2.02f;Fl oa t foo=3.03d;Fl oa t foo=0 x0123;Answer:A,D,F这都是考试原题,有心人可以收集收集,会让你收益匪浅!因为这一套较多,所以我分4 将他罗列出来!310-025Lea ding the wa y in IT testing a nd certifica tion tool s,Question No:1Given:1.publ ic cl a ss test(2.public static void main(String args)3.int i:OxFFFFFFFl;4.int j=i;5.6.)7.)What is the decimal value of j at line 5?A.0B.1C.14D.-15E.An error at line 3 causes compilation to fail.F.An error at line 4 causes compilation to fail.Answer:DQuestion No:2Given: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,EQuestion No:3Exhibit:1.public class test(2.private static int j=0;3.4.private static boolean methodB(int k)(5.j+=k;6.return true;6.)7.8.public static void methodA(int i)9.boolean b:10.b=i 10|methodB(4);11.b=i 10|methodB(8);12.)13.14.public static void main(String args (15.methodA(0);16.system.out.println(j);17.)18.)What is the result?A.The program prints 0”B.The program prints“4”C.The program prints 8”D.The program prints“12”E.The code does not complete.Answer:BQuestion No:4Given1.Public class test(2.Public static void main(String args)(3.System,out.printin(6 3);4.)5.)What is the output?Answer:5Question No:5Given:1.publ ic cl a ss Foo 2.publ ic sta tic void ma in(String 口 a rg s)3.String Buffer a =new String Buffer(A”);4.String Buffer b=new String Buffer(B”);5.opera te(a,b);6.system.out.printl na +b);7.)8.sta tic void opera te(String Buffer x,String Buffery)9.x.a ppend y;10.y=x;1 1.)12.Wha t is the resul t?A.The code compil es a nd printsB.The code compil es a nd prints“A,B”“A,A”.C.The code compil es a nd prints“B,B”.D.The code compil es a nd printsE.The code compil es a nd prints“AB,AB”.F.The code does not compil e beca use ca nnot beoverl oa ded for String Buffer.Answer:DQuestion No:6Exhibit:1.Public class test(2.Public static void stringReplace(String t e x t)(3.Text=text,replace(j,,i);4.)5.6.public static void bufferReplace(StringBuffer text)(7.text=text,append(C”)8.)9.10.public static void main(String args (11.String textString=new String(java”);12.StringBuffer text BufferString=new StringBuffer(“java”);13.14.stringReplace(textString);15.BufferReplace(textBuffer);16.17.System,out.printin(textString+textBuffer);18.19.)What is the output?Answer:javajavaCQuestion No:7E xhibit:1.public class test 2.public static void add3(Integer i)3.int val=i.intValue();4.val+=3;5.i=new Integer(val);6.)7.8.publie static void main(String args )9.Integer i=new Integer(0);10.add3(i);11.system,out.printin(i.intValue();12.13.)What is the result?A.Compilation will fail.B.The program prints 0”.C.The program prints 3”.D.Compilation will succeed but an exception will bethrown at line 3.Answer:BQuestion No:8Given:1.public class ConstOver(2.public ConstOver(int x,int y,int z)3.)4.Which two overload the ConstOver constructor?(ChooseTwo)A.ConstOver()B.Protected int ConstOver()C.Private ConstOver(int z,int y,byte x)D.Public Object ConstOver(int x,int y,int z)E.Public void ConstOver(byte x,byte y,byte z)Answer:A,CQuestion No:9Given:1.public class MethodOver 2.publie void setVar(int a,int b,float c)3.)4.Which two overload the setVar method?(Choose Two)A.Private void setVar(int a,float c,int b)B.Protected void setVar(int a,int b,float c)C.Public int setVar(int a,float c,int b)(returna;)D.Public int setVar(int a,int b,float c)(returna;)E.Protected float setVar(int a,int b,float c)(return c;)Answer:A,CQuestion No:10Given:1.class BaseClass 2.Private float x=1.Of;3.protected float getVar()(return x;)4.5.class Subclass extends BaseClass(6.private float x=2.Of;7./insert code here8.)Which two are valid examples of method overriding?(Choose Two)A.Float getVar()return x;B.Public float getVarreturn x;C.Float double getVar()return x;D.Public float getVar()return x;E.Public float getVar(float f)return f;Answer:B,DQuestion No:11Which two demonstrate an is a”relationship?(ChooseTwo)A.public interface Person public class Employee extends Person B.publie interface Shape public class Employee extends Shape C.public interface Color public class Employee extends Color D.public class Species public class Animal(private Species species;)E.interface Component Class Container implements Component(Private Component chiIdren;)Answer:D,EQuestion No:12Which statement is true?A.An anonymous inner class may be declared as final.B.An anonymous inner class can be declared as private.C.An anonymous inner class can implement multipleinterfaces.D.An anonymous inner class can access final variablesin any enclosing scope.E.Construction of an instance of a static inner classrequires an instance of the enclosing outer class.Answer:DQuestion No 13Given:1.package foo;2.3.public class Outer(4.public static class Inner(5.)6.)Which statement is true?A.An instance of the Inner class can be constructedwith“new Outer.Inner()”B.An instance of the inner class cannot be constructedoutside of package foo.C.An instance of the inner class can only beconstructed from within the outer class.D.From within the package bar,an instance of the innerclass can be constructed with“new inner()nAnswer:AQuestion No 14E xhibit:1.public class enclosingone(2.public class insideone(3.)4.public class inertest(5.public static void main(stringargs)(6.enclosingone eo=new enclosingone();7./insert code here8.)9.)Which statement at line 7 constructs an instance of theinner class?A.InsideOnew ei=eo.new InsideOn();B.Eo.InsideOne ei=eo.new InsideOne();C.InsideOne ei=EnclosingOne.new InsideOne();D.EnclosingOne.InsideOne ei=eo.new InsideOne();Answer:DQuestion No 15Exhibit:1.interface foo 2.int k=0;3.4.5.public class test implements Foo(6.public static void main(String args)(7.int i;8.Test test=new test();9.i=test,k;10.i=Test,k;11.i=Foo.k;12.)13.)14.What is the result?A.Compilation succeeds.B.An error at line 2 causes compilation to fail.C.D.E.An error at line 9 causes compilation to fail.An error at line 10 causes compilation to fail.An error at line 11 causes compilation to fail.Answer:AQuestion No 16Given:1./point X2.public class foo(3.public static void main(Stringargs)throwsException 4.printWriter out=new PrintWriter(new5.java.io.outputStreamWriter(System,out),true;6.out.printin(Hello);7.)8.)Which statement at PointX on line 1 allows this codeto compile and run?A.Import java.io.PrintWriter;B.Include java.io.PrintWriter;C.Import java.io.OutputStreamWriter;D.Include java.io.OutputStreamWriter;E.No statement is needed.Answer:AQuestion No 17Which two statements are reserved words in Java?(Choose Two)A.RunB.ImportC.DefaultD.ImplementAnswer:B,CQuestion No 18Which three are valid declarations of a float?(ChooseThree)A.Float foo=-1;B.Float foo=1.0;C.Float foo=42el;D.Float foo=2.02f;E.Float foo=3.03d;F.Float foo=0 x0123;Answer:A,D,F