one , choice question

1. Which of the following are valid variable names ? ( DEG  )

A.2variable

B. .variable2

C. ._whatavariable

D._3_

E.$anothervar

F.#myvar

G. $_¥

2. Excuse me? “abcd” instanceof Object The returned value is ? (  B   )

A. “abcd”  B. true  C. false  D. String

3. The following statement about method coverage is incorrect :( B  )

A.  Method overrides require that the overridden and overridden methods have the same name , Parameter column and return value

B.  Method override requires that the overridden and overridden methods must have the same access rights ;

C.  Overridden methods cannot throw more exceptions than overridden methods

D.  The method of coverage must not be private of

4.  In the following code snippet :(  A )

String String=”String”;

System.out.println(String);

A. String  B.  hear nothing of  C.  Compilation error  D.  Run error

5.  Which of the following is the correct creation Map Collection mode :(  D )

A. Map m=new Map();

B. Map m=new Map(init capacity, increment capacity);

C. Map m=new Map(new Collection());

D. Map It's an interface , So it cannot be instantiated .

6. About private protected access control characters protected Decorated member variable , The following statement is correct ? ( A  )

A. It can be cited by three categories : The class itself , Other classes in the same package as it , Subclasses of this class in other packages

B.  Can be accessed and referenced in two ways : The class itself , All subclasses of this class

C.  Can only be accessed and modified by the class itself

D. Can only be accessed by classes in the same package

7. The following statements about inheritance . The correct thing is :(B   )

A.  Subclasses can inherit all methods and properties of the parent class ;

B.  Subclasses can inherit the non private methods and properties of the parent class

C.  A subclass can only inherit from its parent class public Methods and properties

D.  A subclass can inherit the methods of its parent class , Not attributes .

8. For construction methods , The following statement is correct :(AC   )

A.  The method name of the constructor must be the same as the class name ;

B.  The construction method must be void Declare return type

C.  Construction methods can be called by programs

D.  If the programmer no longer defines a constructor in the class , The program will report an error .

9. The following is a description of the subclass inheriting the parent constructor , The correct one is :(CD   )

A.  When creating objects of subclasses , Call the subclass's own constructor first , And then call the constructor of the parent class .

B.  A subclass may not call the constructor of the parent class

C.  Subclass must pass super() Keyword calls the constructor of the parent class

D.  A subclass cannot inherit the constructor of a parent class .

10.  In the following statement , The correct thing is :( A  )

A.  Classes are collections of variables and methods

B.  An array is a collection of unordered data

C.  Abstract classes can be instantiated

D.  Class member data must be public

11. When creating objects, you must (  C )

A)  Declare object first , Then you can use the object

B)  Declare object first , Allocate memory space for objects , Then you can use the object

C)  Declare object first , Allocate memory space for objects , Initialize object , Then you can use the object

D)  All the above statements are correct

12. Java in (  C )

A)  A subclass can have more than one parent class , A parent class can also have multiple subclasses

B)  A subclass can have more than one parent class , But a parent class can only have one subclass

C)  A subclass can have a parent , But a parent class can have multiple subclasses

D)  None of this is true

13.Java Language has many advantages and characteristics , Which reflects Java Characteristics of program parallel mechanism ?(B   )

A)  Security            B)  Multiline ( Course ) nature             C)  Cross platform            D)  Portable

14. Character Flow and Byte The difference between streams is ( C  )

A)  The number of bytes read in each time is different      B)  The former has a buffer , The latter did not

C)  The former is character reading and writing , The latter is byte reading and writing   D)  There is no difference between the two , It can be used interchangeably

15. About the following application Description of , The correct thing is (    C       )

1.  class   StaticStuff

2. {

3.                  static  int  x=10;

4.                  static  { x+=5;}

5.                  public  static  void  main(String  args[ ])

6.                  {

7.                       System.out.println(“x=” + x);

8.                  }

9.                  static  { x/=3;}

10.   }

A,4 Line and 9 Line cannot be compiled , Because the method name and return type are missing

B,9 Line cannot be compiled , Because there can only be one static initializer

C, Compile passed , The execution result is :x=5

D, Compile passed , The execution result is :x=3

16. The description of the following program code is correct (     D   )

1.class  HasStatic{

2.    private  static  int  x=100;

3.    public  static  void  main(String  args[  ]){

4.        HasStatic  hs1=new  HasStatic(  );

5.        hs1.x++;

6.        HasStatic  hs2=new  HasStatic(  );

7.        hs2.x++;

8.        hs1=new  HasStatic( );

9.        hs1.x++;

10.       HasStatic.x- -;

11.       System.out.println(“x=”+x);

12.    }

13. }

A, 5 Line cannot be compiled , Because private static variables are referenced

B, 10 Line cannot be compiled , because x Is a private static variable

C, The program is compiled , The output result is :x=103

D, The program is compiled , The output result is :x=102

17. The loop structure in the following options is legal (     C      )

A,while (int  i<7)

{     i++;

System.out.println(“i is “+i);

}

B, int  j=3;

while(j)

{

System.out.println(“ j  is “+j);

}

C,int  j=0;

for(int  k=0; j + k !=10; j++,k++)

{

System.out.println(“ j  is “+ j + “k  is”+ k);

}

D,  int  j=0;

do{

System.out.println( “j  is “+j++);

if (j = = 3) {continue  loop;}

}while  (j<10);

18.      class Test1 As defined below : 1.public  class  Test1{

2.   public  float  aMethod(float  a,float  b){return ..;   }

3.

4.}

Which of the following methods will be inserted into the row 3 It's illegal .(     B    )

A,public  float  aMethod(float  a, float  b,float  c){ return ..;  }

B,public  float  aMethod(float  c,float d){ return.. ;  }

C,public  int  aMethod(int  a, int b){ return ..;  }

D,private  float  aMethod(int a,int b,int c){ return ..;  }

19.      class Test1,Test2 As defined below :

1.  public  class  Test1

2.{ public  float  aMethod(float a,float b) throws

3.  IOException {      }

4. }

5. public  class  Test2  extends  Test1{

6.

7.}

Which of the following methods will be inserted into the row 6 It's illegal .( A     )

A,float  aMethod(float  a,float  b){ }

B,public  int  aMethod(int a,int b)throws  Exception{ }

C,public  float  aMethod(float  p,float q){ }

D,public  int  aMethod(int a,int  b)throws IOException{ }

20.      About the following segments , The correct statement is (   C     )

1.  String  s1=”abc”+”def”;

2.  String  s2=new  String(s1);

3.  if(s1= =s2)

4.     System.out.println(“= = succeeded”);

5.  if (s1.equals(s2))

6.     System.out.println(“.equals()  succeeded”);

A, that 's ok 4 And line 6 Will be implemented            B, that 's ok 4 implement , that 's ok 6 Do not execute

C, that 's ok 6 implement , that 's ok 4 Do not execute         C, that 's ok 4, that 's ok 6 None

21.      Which of the following methods is used to define the execution body of a thread ? (  C     )

A, start()            B,init()               C,run()
              D,synchronized()

22.      Which of the following keywords can be used to mutex an object ?(    D   )

A,transient         B,static               C, serialize         D,synchronized

23.      The following methods are defined , Please select the return type of this method (   D   ).

ReturnType  method(byte x, double y)                            {

return  (short)x/y*2;

}

A,byte                B,short               C,int                   D,double

24          Which of the following is the correct definition of an interface ?(    BD     )

A, interface  B

{  void print(){};}

B, abstract  interface  B

{ void print() ;}

C, abstract  interface  B  extends  A1,A2  //A1,A2 For defined interfaces

{ abstract  void  print(){  };}

D, interface  B

{  void  print();}

25.   A Derived subclasses B,B Derived subclasses C, And in Java The source code has the following declaration :

1.    A  a0=new  A();

2.    A  a1 =new  B();

3.    A  a2=new  C();

Which of the following statements is true ? (    D    )

A, Only the first 1 Lines can be compiled  B, The first 1,2 Lines can be compiled , But the first 3 Line compilation error

C, The first 1,2,3 Lines can be compiled , But the first 2,3 Error running row

D, The first 1 that 's ok , The first 2 Line and page 3 The declaration of the line is correct

26.   hypothesis A Class has the following definitions , set up a yes A Class , Which of the following statements is wrong to call ?(   C    )

class  A

{     int  i;

static  String  s;

void  method1() {   }

static  void  method2()  {   }

}

A,System.out.println(a.i);B,a.method1();  C,A.method1();

D,A.method2()

27.   The following statement about inheritance is correct (   A    ).

A, stay Java Only single inheritance is allowed in a class

B, stay Java A class in can only implement one interface

C, stay Java A class in cannot inherit a class and implement an interface at the same time

D, stay Java Only single inheritance is allowed in the interface

28.    Give the following code , Which of the following statements is true about the program ?( C      )

public class Person{

static int arr[] = new int[5];

public static void main(String a[]) {

System.out.println(arr[0]);}

}

}

A, An error will occur at compile time        B, Compile time correct , An error will occur at runtime

C, Output Zero            D, Output null

29  in use interface When declaring an interface , Can only be used ( D      ) Modifier modifies the interface .

A,private            B,protected         C,private  protected   D,public

30.  Compile and run the following program , Which of the following is true (   D    )

1.  class  A{

2.      protected  boolean  equals(){

3.           return  super.equals();

4. }

5. }

A, Compile and run without exception     B, Compilation passed but an error occurred while running

C, that 's ok 2 error , Failed to compile successfully     D, Failed to compile successfully , that 's ok 3 error

31.   Have statement String s=”hello world”; , Which of the following is illegal ?(  B     )

A,int i=s.length();       B,s>>>=3;

C,String ts=s.trim();    D,String t=s+”!”;

32.      Read the following code :

import java.io.*;

import java.util.*;

public class foo{

public static void main (String[] args){

String s;

System.out.println("s=" + s);

}

}

The output should be :(   C    )

A. The code is compiled , And output “s=”

B. The code is compiled , And output “s=null”

C. because String s Not initialized , The code cannot be compiled

D. The code is compiled , But captured  NullPointException abnormal

33.      After compiling and running the following program , The description of the output results is correct  (  C    )

public  class   Conditional{

public  static  void  main(String  args[ ]){

int  x=4;

System.out.println(“value  is  “+ ((x>4) ? 99.9:9));

}

}

A. The output result is :value  is  99.9      B. The output result is :value  is  9

C. The output result is :value  is  9.0

D. Compilation error

34.  Complete the following code int [ ]  x = new int[10]; after , Which of the following statements is correct ( A    )

A.x[9] by 0

B.x[9] Undefined

C.x[10] by 0

D.x[0] Empty

35.      About the following segments , The correct statement is ( C     )

1.  String  s1=“a”+“b”;

2.   String  s2=new  String(s1);

3.    if(s1= =s2)

4.       System.out.println(“= =  is succeeded”);

5.     if (s1.equals(s2))

6.        System.out.println(“.equals() is succeeded”);

A. that 's ok 4 And line 6 Will be implemented            B. that 's ok 4 implement , that 's ok 6 Do not execute

C. that 's ok 6 implement , that 's ok 4 Do not execute         C. that 's ok 4, that 's ok 6 None

36.      The running result of the following program is :(  C    )

public class Increment{

public static void main(String args[]){

int c;

c = 2;

System.out.println(c);

System.out.println(c++);

System.out.println(c);

}

}

A.2 2 2          B.2 3 3    C.2 2 3   D.3 4 4

37      if a The value of is 3 Time , After the following program segments are executed ,c What is the value of ?(  C    )

if ( a>0 )

if ( a>3 )  c = 2;

else c = 3;

else c = 4;

A,1           B,2          C,3          D,4

38.       Which of the following operators has the highest priority ?  (   D    )

A,&&                       B,||

C,!                          D,( )

39.    Execute statement int i = 1, j = ++i  +  ++i  + i--;  after i And j The values of are (  D     ).

A,2 And 6               B,3 And 8

C,3 And 5               D,2 And 8 (++i Operation before value )

40.      Which of the following loops will cause an endless loop ?(  C     )

A,for (int k = 0; k < 0; k++)

B,for (int k = 10; k > 0; k--)

C,for (int k = 0; k < 10; k--)

D,for (int k = 0; k > 0; k++)

41.      There are the following program segments :

int a = b = 5;

String s1 = " I wish you good grades today !";

String s2 = s1;

Then expression a == b And s2 == s1 The results are :( A     ).

A,true And true               B,false And true

C,true And false                D,false And false

42.  stay Java The method modified by what keyword can be called directly through the class name ?(  A    )

A,static         B,final       C,private          D,void

43.      There are the following program segments :

int total = 0;

for ( int i = 0; i < 4; i++ ){

if ( i == 1) continue;

if ( i == 2) break;

total += i;

}

After the program segment is executed total The value of is :(   A    ).

A,0                    B,1                     C,3                     D,6

44. If you want a variable to be accessed and called only by the class itself , Which of the following access control modifiers should be used ( A  ).

A,private                    B,protected

C,private  protected         D,public

45. To construct ArrayList Class , This class inherits List Interface , Which of the following is correct ?(  B   )

A,ArrayList myList=new Object();

B,List myList=new ArrayList();

C,ArrayList myList=new List();

D,List myList=new List();

46.      Indicate the correct expression ( BD  )

A, byte=128;

B, Boolean=null;

C, long l=0xfffL;

D, double=0.9239d;

47.      Indicate the results of the following procedures (   B   )

public class Example{

String str=new String("good");

char[] ch = {'a','b','c'};

public static void main(String args[]){

Example ex=new Example();

ex.change(ex.str,ex.ch);

System.out.print(ex.str+" and ");

Sytem.out.print(ex.ch);

}

public void change(String str,char ch[]){

str="test ok";

ch[0]='g';

}

}

A, good and abc

B, good and gbc

C, test ok and abc

D, test ok and gbc

48      Run the following procedure ,  What will happen (  D     )

public class X extends Thread implements Runnable{

public void run(){

System.out.println("this is run()");

}

public static void main(String args[]) {

Thread t=new Thread(new X());

t.start();

}

}

A, The first line produces a compilation error

B, The sixth line produces a compilation error

C, The sixth line will produce a running error

D, The program runs and starts

49.          The following statements have warnings or errors during compilation (  ABCD     )

A. float f=3.14;

B. char c=”c”;

C. Boolean b=null;

D. int i=10.0;

50.          The following code snippet is given ,  Which line will cause a compile time error ?(  D  )

1) public class Test {

2)   int n = 0;

3)   int m = 0;

4)   public Test(int a) { m=a; }

5)   public static void main(String arg[]) {

6)     Test t1,t2;

7)     int j,k;

8)     j=3; k=5;

9)     t1=new Test();

10)    t2=new Test(k);

11)  }

12) }

A.  that 's ok 1                 B.  that 's ok 4                 C.  that 's ok 6                 D.  that 's ok 9

51.          Classes in the following program ClassDemo A static variable is defined in sum, Analyze the output of the program segment .

(  C  )

class ClassDemo {

public static int sum=1;

public ClassDemo() {

sum = sum + 5;

}

}

public class ClassDemoTest{

public static void main(String args[]) {

ClassDemo demo1=new ClassDemo();

ClassDemo demo2=new ClassDemo();

System.out.println(demo1.sum);

}

}

A. 0                      B. 6                      C. 11                  D. 2

52.      The following statement about array declaration and initialization has a syntax error ?(  C     )

A)int a1[]={3,4,5};

B)String a2[]={"string1","string1","string1"};

C)String a3[]=new String(3);

D)int[][] a4=new int[3][3];

53.      The following method , When input is 2 What is the return value when ?(   D    )

public int getValue(int i) {

int result = 0;

switch (i) {

case 1:

result = result + i;

case 2:

result = result + i * 2;

case 3:

result = result + i * 3;

}

return result;

}

A)0                    B)2                    C)4                     D)10

54.
    getCustomerInfo() The method is as follows ,try Three types of exceptions can be caught in , If an error occurs during the operation of the method IOException, What results will be output (
 A  )

public void getCustomerInfo() {

try {

// do something that may cause an Exception

} catch (java.io.FileNotFoundException  ex){

System.out.print("FileNotFoundException!");

} catch (java.io.IOException  ex){

System.out.print("IOException!");            } catch (java.lang.Exception  ex){

System.out.print("Exception!");

}

}

A)IOException!

B)IOException!Exception!

C)FileNotFoundException!IOException!

D)FileNotFoundException!IOException!Exception!

55      Create a new stream object , Which of the following options has the wrong code ?(  B    )

A)new BufferedWriter(new FileWriter("a.txt"));

B)new BufferedReader(new FileInputStream("a.dat"));

C)new GZIPOutputStream(new FileOutputStream("a.zip"));

D)new ObjectInputStream(new FileInputStream("a.dat"));

56.     Java Important interfaces in the collection framework java.util.Collection Many methods are defined . Which method in the options

no Collection Interface defined ?(  C     )

A)int size()

B)boolean containsAll(Collection c)

C)compareTo(Object obj)

D)boolean remove(Object obj)

57.      A thread is in a thread state at any time (thread state), For example, running status , Blocking state ,

Ready status, etc . Which thread state in the options can a thread reach the running state directly ?(  D     )

A) Death state

B) Blocking state ( object lock Pool )

C) Blocking state ( object wait Pool )

D) Ready status

58.      Which line of code in the option can replace the code in the title //add code here Without generating compilation errors ?(  A     )

public abstract class MyClass {

public int constInt = 5;

//add code here

public void method() {

}

}

A)public abstract void method(int a);

B)value = value + 5;

C)public int method();

D)public abstract void anotherMethod() {}

59.      Here is People and Child Class definition and construction method , Each construction method outputs a number . In execution new

Child("mike") Which constructor methods are called in sequence when ? Please select output result  (   D   )

class People {

String name;

public People() {  System.out.print(1); }

public People(String name) {

System.out.print(2);

this.name = name;

}

}

class Child extends People {

People father;

public Child(String name) {

System.out.print(3);

this.name = name;

father = new People(name + ":F");

}

public Child(){ System.out.print(4); }

}

A)312              B) 32

C)    432              D) 132

60.      The code in which of the following options does not define an inner class , Or the inner class is defined incorrectly ? (    C   )

A)public Class Line {

int length;

Class Point {// Internal class code }

}

B)    public Class Line {

public Point getPoint() {

return new Point(){// Internal class code };

}

}

C)    public Class Line {

// External class code

}

Class Point {// Internal class code }

D) public Class Line {

public int calcLength() {

Class Point {// Internal class code }

}

}

two , Programming problem

1  Array  int [] a={9,5,7,8,1,3,2,6,4}  Bubble sort

2  Write a singleton design pattern

3  Enter ten lines of data on the keyboard , Until input quit Just exit the program , Save the entered data in D:\temp\info.txt in , Create the file if it does not exist .

4  Simulation generation 1 Classes , The class has 9 Student object , Simulate the following operations with sets .

A. Add another student to the class

B. The student number is S001 Your name is changed to ” Zhang Heng ”

C. Count the average score of all students

D. Save all student information to a file student.txt in

5  Simulate four threads on the same data I Operate

1 Number and 3 Thread No. 1 does plus one

2 Number and 4 Thread 1 minus 1

Technology
©2019-2020 Toolsou All rights reserved,
【Java8 New features 1】Lambda Expression summary What is a process , Concept of process ?hdfs dfs Common basic commands java When creating objects, you must _Java Basic test questions Generation of random numbers + Figure guessing game When will we enter the old generation ?HDFS Common commands ( summary ) It is never recommended to spend a lot of time studying for employment pythonmacOS Big Sur The installation could not be completed Big Sur Why can't I install it ?Python pyttsx3| Text reading ( Various languages )