|
1. .Given twojavaProcedure,As follows:Text.javaThe result of the compilation run is (choose one) pubilc interface Face{ int count = 40; } pubilc class Text implements Face{ private static int counter; pubilc static void main(String[]args){ System.out.println( counter ); } } A、40 B、41 C、0 D、1 2. JavaA value entered by the user is read in the program, and a custom exception is required to be created if the input value is greater than10, usethrowThe statement explicitly raises an exception, and the exception output message is "something’s wrong! ", the sentence is (choose one) A、if (I>10) throw Exception("something’s wrong!"); B、if (I>10) throw Exception e ("something’s wrong!"); C、if (I>10) throw new Exception("something’s wrong!"); D、if (I>10) throw new Exception e ("something’s wrong!"); 3. JavaClasses in programs are defined as follows: class Demo { private int[] count; public Demo(){ count=new int[10]; } public void setCount(int ct,int n){ count[n]=ct; } public int getCount(int n){ return count[n]; } public void showCount(int n){ System.out.println("Count is "+count[n]); } } in creationDemoinstance of the class, by callingshowCount(9)The result of the method is (choose one) A、Count is 0 B、Count is null C, compilation errors D, runtime errors 4. javaThe program contains the following code: DataInputStream din = new DataInputStream( new BufferedInputStream(new FileInputStream("employee.dat") )); Assuming inemployee.datThe file contains only the following characters:abcdefg。 Then:System.out.println(din.read())Print on the screen (choose one) A、A B、B C、97 D、98 5. javaIn the language, the following are based on all classes that handle output operations (choose one) A、DataOutput B、OutputStream C、BufferedOutputStream D、IOStream 6. Java, when using the () modifier, a class can be accessed by other classes in the same package or different packages. (Choose one) A、private B、protected C、public D、friendly 7. public class Test { public static void main(String args[]){ EqTest e = new EqTest(); e.show(); } } class EqTest{ String s = "Java"; String s2 = "java"; public void show(){ //Place the test code here {System.out.println("Equal"); } else {System.out.println("Not equal"); } } } On the topJavaThe comment line position of the code, placing () the test code will output an "equal" result. (Choose one) A、if(s==s2) B、if(s.equals(s2)) C、if(s.equalsIgnoreCase(s2)) D、if(s.noCaseMatch(s2)) 8. Packagepack1Classclass1There are member methods: protected void method_1(){…}, private void method_2(){…}, public void method_3(){…}andvoid method_4(){…},In the packagepack2classclass2beclass1The subclass is in youclass2(choose two) A、method_1 B、method_2 C、method_3 D、method_4 9. Compile and run the followingJavaProcedure: class A{ int var1=1; int var2; public static void main(String[] args){ int var3=3; A a = new A(); System.out.println(a.var1+a.var2+var3); } } will be generated( )Result. (Choose one) A、0 B、4 C、3 D, the code cannot be compiled becausevar2Not initialized at all 10. Compile and run the followingJavaCode snippet char c = 'a'; switch (c) { case 'a': System.out.println("a"); default: System.out.println("default"); } The output result is (choose one) A, the code cannot be compiled becauseswitchThere is no legal expression for a statement B、a default C、a D、default 11. Analyze the followingJavaCode: class A{ public static void main(String[] args){ method(); } static void method(){ try{ System.out.println("Hello"); } finally{ System.out.println("good-bye"); } } } After the compilation runs, the output is (choose one) A、“Hello” B、“good-bye” C、“Hello good-bye” D, the code cannot be compiled 12. Analyze the followingJavaProcedure: public class ExceptionTest { public static void main(String[] args) throws Exception { try { throw new Exception(); } catch(Exception e){ System.out.println("Caught in main()"); } System.out.println("nothing"); } } The output result is (choose one) A、Caught in main()nothing B、Caught in main() C、nothing D, without any output 13. GivesJavaThe code is as follows, To print outlistcontent stored in the,The following statement is correct (choose two) ArrayList list= new ArrayList(); list.add("a"); list.add("b"); A、System.out.print(list); B、System.out.print(list.toArray()); C、System.out.print(list.toString()); D、System.out.print(list.get(0)); 14. GivesJavaCode, as follows: abstract class Shape{ abstract void draw(); } To createShapesubclasses of classesCircle, the following code is correct (choose two) A、class Circle extends Shape{int draw(){}} B、abstract class Circle extends Shape{ } C、class Circle extends Shape{void draw(); } D、class Circle extends Shape{void draw(){}; } 15. GivesjavaThe code is as follows: compile run, and the result is (choose one) public static void main(String[] args) { String s ; System.out.println( "s=" + s); } A, compilation errors B, compile passes, but there is a runtime error C, normal operation, outputs=null D, normal operation, outputs= 16. GivenjavaThe code, as follows: When running, an exception of type () is generated. (Choose one) String s = null; s.concat("abc"); A、AritthmeticException B、NullpointerException C、IOException D、EOFException 17. GivesjavaThe code snippet is as follows: Integer a = new Integer(3); Integer b = new Integer(3); System.out.println(a==b); After running, this code will be output (choose one) A、1 B、0 C、true D、false 18. GivesjavaThe code is as follows,dThe value range is (choose one) double d = Math.random(); A、d>=1.0 B、d>=0.0,moreoverd<1.0 C、d>=0.0,moreoverd<Double.MAX_VALUE D、d>=1.0,moreoverd<Double.MAX_VALUE 19. GivenJavaThe code is as follows, and when runtime, it will be generated( )type of anomaly. (Choose one) String s = null; s.concat("abc"); A、ArithmeticException B、NullPointerException C、IOException D、EOFException 20. Given so-and-soJavaproceduralmainThe method is as follows, the result of the program compilation and run is (choose one) public static void main(String[]args){ String str = null; str.concat("abc"); str.concat("def"); System.out.println(str); } A、null B、abcdef C, compilation errors D, abnormalities occur during runtime 21. Given as followsJAVAProgram fragments: class A{ public A(){ system.out.println("A"); } } class B extends A{ public B(){ System.out.println("B"); } public static void main(String[] args){ B b = new B(); } } The above procedures will (choose one) A, cannot be compiled B, through compilation,The output is: A B C, through compilation,The output is: B D, through compilation,The output is: A 22. Given as followsJavacode, will be in the compilation time( )An error occurred. (Choose one) class Parent{ } class Child extends Parent{ public static void main(String args[]){ Parent p1 = new Child(); //First line Parent p2 = new Parent(); //Second line Child c1 = new Child(); //Third row Child c2 = new Parent(); //Fourth line } } A, the first line B, the second line C, the third line D, the fourth line 23. Given as followsJavaCode, compile runtime, below( )The value of the statement istrue。 (Choose two) String s = "hello"; String t = "hello"; String e = new String("hello"); char[] c = {'h','e','l','l','o'}; A、s.equals( t ) B、t.equals( c ) C、t.equals( e ) D、t==c 24. Given oneJavaThe program code is as follows: After running the compilation, the output result is (choose one) pubilc class Test{ int count = 9; pubilc void count1(){ int count = 10; System.out.println("count1" + count); } pubilc void count2(){ System.out.println("count2" + count); } pubilc static void main(String args[]){ Test t = new Twst(); t.count1(); t.count2(); } } A、count1=9 count2=9 B、count1=10 count2=9 C、count1=10 count2=10 D、count1=9 count2=10 25. Given oneJavaThe code fragment of the program is as follows, after running, the correct output result is (choose one) String s="hello,world"; s.replace(","," "); System.out.println(s); A、hello world; B、hello, world C、HELLO WORLD; D、HELLO ,WORLD; 26. Give onejavaThe methodological structure of the procedure is as follows: public Integer change(String s){ } The following methodology implementation statements are correct (choose two) A、return new Integer(s); B、return s; C、Integer t = Integer.valueOf(s); return t; D、return s.getInteger(); 27. The interface is defined as follows: interface A { int method1(int i); int method2(int j); } kindBImplements interfacesA, below( )That's right. (Choose one) A、class B implements A {int method1() { }int method2() { }} B、class B {int method1(int i) { }int method2(int j) { }} C、class B implements A {int method1(int i) { }int method2(int j) { }} D、class B extends A {int method1(int i) { }int method2(int j) { }} 28. As followsJavaCode snippet, embodying the concept of (). (Choose one) public void aMethod(String s){....} public void aMethod(int i){.........} public void aMethod(int i,float f){.....} A, more inheritance B, heavy load C, rewrite D, polymorphism 29. To judge two stringss1ands2Whether they are equal or not, they should be used (choose one) A、if (s1==s2) B、if (s1=s2) C、if (strcpy(s1,s2)) D、if (s1.equals(s2)) 30. The following descriptions in the class are incorrect (choose one) AA class is a group of objects with the same characteristics, common behaviors and common relationships B, class is the specific manifestation of the object in the real world C, similar objects are grouped into a class, each describing a set of independent objects D, object is an instance of a class, and class structure is a practical form of object abstraction 31. The output of the following program is (choose one) class A2 extends A1 { A2(){ System.out.println("A2"); } public static void main(String args[]){ new A2(); } } class A1{ A1(){ System.out.println("A1"); } } A、A1 B、A2 C、A1A2 D、A2A1 32. The following are:JavaSome declarations in the program, one of the options that can be compiled is (choose one) String s1 = new String("Hello"); String s2 = new String("there"); String s3 = new String(); A、s3 = s1 + s2 B、s3 = s1& s2 C、s3 = s1 || s2 D、s3 = s1 - s2 33. Research the followingJavaCode: public class testException{ public static void main(String args[]){ int n[]={0,1,2,3,4}; int sum=0; try { for(int i=1; i<6; i++) sum=sum+ n; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsExpception e) { System.out.println("The array crosses the boundary"); } finally{ System.out.println("End of the procedure"); } } } The output will be (select one) A、10 Array Outbounds program ends B、10 End of the procedure C, the array is out of bounds, and the procedure ends D, the end of the procedure 34. To useJavaCreate a new directory with an instance of class () below. (Choose one) A、File B、FileoutputStream C、Printwriter D、BufferedReader 35. BelowJavain the statement,( )Can construct oneDataOutputStreamObject. (Choose one) A、new DataOutputStream(new FileOutputStream("abc.txt")); B、new DataOutputStream(new OutputStream("abc.txt")); C、new DataOutputStream(new FileWriter("abc.txt")); D、new DataOutputStream(new FileInputStream("abc.txt")); 36. InJ2EE, the compilation error in the following code is (choose one) A、File f = new File("/","autoexec.bat"); B、DataInputStream din = new DataInputStream(new FileInputStream("autoexec.bat")); C、InputStreamReader in = new InputStreamReader(System.in); D、OutputStreamWriter out = new OutputStreamWriter(System.in); 37. InJ2SE, the sorted collection class of the following elements is (choose one) A、LinkedList B、Stack C、Hashtable D、TreeSet 38. InJava.langPackagedMathIn the class, the method of finding the maximum value is (select one) A、Max() B、Min() C、Abs() D、Ceil() 39. Injavacan be separately withfinallyThe blocks used together with the statement are (choose one) A、try B、catch C、throw D、throws 40. InJavaIn a language, when a variable of a class is declared as protectedThe following statements are correct (choose two) A, only members of the same class can access it B, any other class in a different package will be able to access it C, any other class in the same package can access it D, subclasses in different packages can access the variable 41. InJavaIf you have the following class definition: abstract class Shape{ abstract void draw(); } Class Square extends Shape{} If you try to compile the above code will happen (choose one) A, everything is successfully compiled B、Shapecan be compiled,SquareCannot compile C、Squarecan be compiled,ShapeCannot compile D、Shape,SquareNone of them can be compiled 42. InJavaIn the language, Xiao Ming was in his bagmypackageclassMy_Class, inmypackageSubpackagemysubpackageThere is also a category in the middleMy_Class。 Xiao Ming used.import mypackage: Introduce the package and execute the statement in it:My_Class NewClass=New My_Class();will occur (select one) A, create a classmypackage. My_ClassObject B, create a classmypackage. Mysubpackage.My_Classobject C, the statement is wrong D, create a classmypackage. My_Classobject and a classmypackage. Mysubpackage.My_Classobject 43. InJavaIn language, Xiao Ming is in his classSquareRootThe method is defined in themethod_Awith a statement: double my_result=Math.sqrt(1000); He needs to import (choose one) A、Java.awt.* B、Java.Math.* C、Java.util.Math.* DNone of the above is true 44. InJavaMedium,()The interface is located at the top level of the collection framework. (Choose one) A、Map B、Collection C、Set D、List 45. InJAVAmedium,comMethods of a certain class in the package can be modified by using the following () access modifierscom.dbsubclass in the package, but cannot be accessed bycom.dbOther class access. (Choose one) A、private B、protected C、public D、friendly 46. InJavaIn the middle, callMath.random()The result that the method might return is (). (Choose one) A、132.34 B、0.342 C、29.34E10 D、1.0009 47. InJavaIn the middle, callMath.random()The result that the method may return is (choose one) A、132.34 B、0.342 C、29.34E10 D、1.0009 48. Injava, the keywords that define the interface are (choose one) A、class B、interface C、extends D、implements 49. InJavaAccording to your understanding, the following methods( )It can't be a classOrangeconstruction method. (Choose one) A、Orange(){…} B、Orange(…){… } C、public void Orange(){…} D、public Orange(){…} 50. InJava, Guan Jian () makes the class unable to derive subclasses. (Choose one) A、final B、public C、private D、volatile doc file download reply can be seen:Tourists, if you want to see the hidden content of this post, please Reply
|