1、大数据基础技能试题及答案Java基础1. Which of the following will compile correctly?A) float f=10f;B) float f=10.1;C) float f=10.1f;D) byte b=10b;2. Which declarations of identifiers are legal A. $persons B. TwoUsers C. *point D. this E. _endline3. Which statement of assigning a long type variable to a hexadecimal v
2、alue is correct A. long number = 345L;B. long number = 0345;C. long number = 0345L;D. long number = 0x345L 4. Which of the following fragments might cause errors A. String s = Gone with the wind;String t = good ;String k = s + t;B. String s = Gone with the wind;String t;t = s3 + one;C. String s = Go
3、ne with the wind;String standard = s.toUpperCase();D. String s = home directory;String t = s - directory;5. Which are syntactically valid statement at/ point x class Person private int a;public int change(int m) return m; public class Teacher extends Person public int b;public static void main(Strin
4、g arg)Person p = new Person();Teacher t = new Teacher();int i;/ point xA. i = m;B. i = b;C. i = p.a;D. i = p.change(30);E. i = t.b. 6. Which layout manager is used when the frame is resized the buttonss position in the Frame might be changed A. BorderLayoutB. FlowLayoutC. CardLayoutD. GridLayout 7.
5、Given the following code fragment:1) public void create() 2 Vector myVect;3 myVect = new Vector(); 4 Which of the following statements are true A. The declaration on line 2 does not allocate memory space for the variable myVect.B. The declaration on line 2 allocates memory space for a reference to a
6、 Vector object.C. The statement on line 2 creates an object of class Vector.D. The statement on line 3 creates an object of class Vector.E. The statement on line 3 allocates memory space for an object of class Vector 8. Which of the following answer is correct to express the value 8 in octal number
7、A. 010B. 0x10C. 08D. 0x8 9. Which are not Java keywords A. TRUEB. sizeofC. constD. superE. void 10. Which of the following statements are true A. The equals() method determines if reference values refer to the same object.B. The = operator determines if the contents and type of two separate objects
8、match.C. The equals() method returns true only when the contents of two objects match.D. The class File overrides equals() to return true if the contents and type of two separate objects match. 11. Which statements about inheritance are true A. In Java programming language only allows single inherit
9、ance. B. In Java programming language allows a class to implement only one interface.C. In Java programming language a class cannot extend a class and implement a interface together.D. In Java programming language single inheritance makes code more reliable. 12. 1) class Person 2 public void printVa
10、lue(int i, int j) /*/ 3 public void printValue(int i)/*.*/ 4 5) public class Teacher extends Person 6 public void printValue() /*.*/ 7 public void printValue(int i) /*.*/8 public static void main(String args)9 Person t = new Teacher();10 t.printValue(10);11 12 Which method will the statement on line
11、 10 call A. on line 2B. on line 3C. on line 6D. on line 7 13. Which are not Java primitive types A. shortB. BooleanC. unitD. float 14、The method resume() is responsible for resuming which threads execution A. The thread which is stopped by calling method stop()B. The thread which is stopped by calli
12、ng method sleep()C. The thread which is stopped by calling method wait()D. The thread which is stopped by calling method suspend()15. Which of the following range of int is correct A. -27 27-1 B. 0 232-1 C. -215 215-1 D. -231 231-1 16. Which keyword should be used to enable interaction with the lock
13、 of an object The flag allows exclusive access to that object. A. transientB. synchronizedC. serializeD. static 17. Which is the return type of the method main() A. intB. voidC. booleanD. static 18. Given the following code:if (x0) System.out.println(first); else if (x-3) System.out.println(second);
14、 else System.out.println(third); Which range of x value would print the string second A. x 0B. x -3C. x = -3D. x -3 19、Which of the following answer is correct to express the value 10 in hexadecimal number A. 0xAB. 0x16C. 0AD. 016 20. Which statements about the garbage collection are true A. The pro
15、gram developer must create a thread to be responsible for free the memory.B. The garbage collection will check for and free memory no longer needed.C. The garbage collection allow the program developer to explicity and immediately free the memory.D. The garbage collection can free the memory used ja
16、va object at expect time. 21、Given the following code:1) public class Test 2 int m, n;3 public Test() 4 public Test(int a) m=a; 5 public static void main(String arg) 6 Test t1,t2;7 int j,k;8 j=0; k=0;9 t1=new Test();10 t2=new Test(j,k);11 12 Which line would cause one error during compilation A. lin
17、e 3B. line 5C. line 6D. line 10 22、Given the uncompleted code of a class:class Person String name, department;int age;public Person(String n) name = n; public Person(String n, int a) name = n; age = a; public Person(String n, String d, int a) / doing the same as two arguments version of constructor
18、/ including assignment name=n,age=adepartment = d;Which expression can be added at the doing the same as. part of the constructor A. Person(n,a);B. this(Person(n,a);C. this(n,a);D. this(name,age).23、Which of the following statements about variables and their scopes are true A. Instance variables are
19、 member variables of a class.B. Instance variables are declared with the static keyword.C. Local variables defined inside a method are created when the method is executed.D. Local variables must be initialized before they are used.24、public void test() try oneMethod();System.out.println(condition 1)
20、; catch (ArrayIndexOutOfBoundsException e) System.out.println(condition 2); catch(Exception e) System.out.println(condition 3); finally System.out.println(finally); Which will display if oneMethod run normally A. condition 1B. condition 2C. condition 3D. finally25、Given the following code:public cla
21、ss Test void printValue(int m)do System.out.println(The value is+m);while( -m 10 )public static void main(String arg) int i=10;Test t= new Test();t.printValue(i);Which will be output A. The value is 8 B. The value is 9C. The value is 10D. The value is 1126、Which of the following statements about dec
22、laration are true A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.C. Declaration of nonprimitive types such as String, Vector an
23、d so on does not allocate memory space for the object.D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.27、In the Java API documentation which sections are included in a class document A. The description of the class and its purposeB. A list
24、of methods in its super classC. A list of member variableD. The class hierarchy28、Given the following code:1) public void modify() 2) int i, j, k;3) i = 100;4) while ( i 0 ) 5) j = i * 2; 6) System.out.println ( The value of j is + j );7) k = k + 1;8) i-;9) 10 Which line might cause an error during
25、compilation A. line 4B. line 6C. line 7D. line 829、Which of the following statements about variables and scope are true A. Local variables defined inside a method are destroyed when the method is exited.B. Local variables are also called automatic variables. C. Variables defined outside a method are
26、 created when the object is constructed.D. A method parameter variable continues to exist for as long as the object is needed in which the method is defined.30、A class design requires that a member variable cannot be accessible directly outside the class. Which modifier should be used to obtain the
27、access control A. publicB. no modifierC. protectedD. private 31、Given the following code fragment:1) String str = null;2) if (str != null) & (str.length() 10) 3 System.out.println(more than 10);4 5) else if (str != null) & (str.length() 5) 6 System.out.println(less than 5);7 8) else System.out.print
28、ln(end); Which line will cause error A. line 1B. line 2C. line 5D. line 8 32、Which statements about Java code security are true A. The bytecode verifier loads all classes needed for the execution of a program.B. Executing code is performed by the runtime interpreter.C. At runtime the bytecodes are l
29、oaded, checked and run in an interpreter.D. The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources. 33、 Given the following code:public class Personint arr = new int10;public static void main(String a) System.out.println(arr1);Which statement is correct A. When compilation some error will occur.B. It is correct when compilation but will cause error when running.C. The output is zero.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1