[Java] practice question bank fill in the blanks

2. Fill in the blanks

1. The three main steps required to develop and run a Java program are editing the source program ,         

     Compile and generate bytecode      and interpret and run bytecode .               

2. Among the basic data types of Java, the char type adopts the Unicode encoding scheme, and each Unicode code occupies

Use 2 bytes of memory space, so that whether it is a Chinese character or an English character, it occupies         

Use 2 bytes of memory space.         

3. Suppose x = 2, then the value of the expression ( x + + )/3 is  .          

4. If x = 5, y = 10, then the logical values ​​of x < y and x >= y are true and  false respectively .             

5. An abstract   method is a method with only a method header and no specific method body and operation implementation. The method must be defined in an abstract class. A final method is one that cannot be redefined by subclasses of the current class.     

6. The statement to create a package named MyPackage is package MyPackage ;   ,

The position of the statement should be placed in the program: it should be the first sentence of the program  .                 

7. There is an array definition: int MyIntArray[ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70}; then the output result after executing the following statements is   120 .         

    int s = 0 ;

    for (int i = 0 ; i < MyIntArray.length ; i + + )

         if ( i % 2 = = 1 )    

s += MyIntArray[i] ;

   System.out.println(s);

8. In a Java program, only single inheritance can be achieved through the definition of a class, but multiple  inheritance can be achieved through the definition of an interface.          

2. Fill in the blanks

1. If the class MyClass is declared as public, its file name must be ( MyClass.java ) to compile normally.

2. The single-line comment in the Java program is (  //  ), and the multi-line comment is (  /* */  ).

3. There are two kinds of Boolean constants in Java, they are ( true ) and ( false ).

4. There are two keywords used to define decimals in Java: ( float ) and ( double ), the precision of the latter is higher than that of the former.

5. The operator used to compare two numbers for equality in Java is: ( == ), and the operator used for unequal comparison is ( <> ).

6. The statement to define a variable str of string type in Java is: ( String str; , the statement to define an integer array a with 10 elements is: ( int [] arr = new int[10]; .

7. The command to import the class in the mypackage package is import mypackage.*;  ) .

8. When declaring an array int arr[] = new int[5];, it means that the variable type stored in this array is ( int ), the array name is ( arr ), the size of the array is ( 5 ), and the array elements Subscripts can be used in the range ( 0 to 4 ) .

9. Suppose x=13, y=4, then the value of the expression x%y != 0 is ( true ), and its data type is ( boolean ).

10. Exception handling is a program block composed of three keys ( try ), ( catch ) and finally block.

11. The output result of the following program segment is ( triangle )

int x = 5, y = 6, z = 4;

if (x + y > z && x + z > y && z + y > x)

System.out.println ( "triangle" ) ;

else

System.out.println ( "not a triangle" );

12. The execution result of the following program segment is ( 6 5 4 3 2 )

int a[] = { 2, 3, 4, 5, 6 };

for (int i = a.length - 1; i >= 0; i--)

System.out.print(a[i] + "");

1. Fill in the blanks

1. The reserved word for defining a class is (  class ), and the reserved word for defining an interface is (    interface  ).      

2. Socket is also commonly called (   socket   ) and is used to describe (   IP address  ) and (  port  ). 

3. The priority of the thread is between  1   ) and (   10   ), the larger the value (  the more urgent the task  ).

4. A construction method is a special member method, and the construction method name is the same as (  class name  ).

5. The Java language only allows single inheritance, which means that each class can only have one (  parent class  ).

6. The extension of the Java source program is (  .java  ), and the extension of the compiled program is (  .class  ).

7. A resource that can only be accessed by one thread at a time is called (  critical resource  ). Code that accesses critical resources (  critical code  ).

8. In a multi-threaded system, there are two relationships between multiple threads (  synchronization  ) and (  mutual exclusion  ).

おすすめ

転載: blog.csdn.net/CE00001/article/details/130163304