A total of 40 choice questions, 2.5 points per question. Multiple-choice mistakes are all wrong, the full score.
Single topic:
1. Which of the following statements is wrong? B
A. int i=10;
B. float f=1.1;
C. Double d=34.4;
D. Byte b=127;
2. Which of the following is not a keyword in Java? C
A. Public
B. True
C. Main
D. Class
3. Which of the following statements does not produce a compilation error? C
A. Float a = 2.0;
B. Char c = "a";
C. Byte B = 25;
D. Boolean d=0;
4. Which of the following programs is correct C
A. Byte a=0,b=3; byte c =a+b;
B. Short S = 23; s=s+12;
C. Short s=23; s+=12;
D. float f = 23+23.23;
5. The size of the byte type is a
A.-128 ~ 127
B.-228 ~128
C.-255 ~ 256
D.-255 ~ 255
6. What are the results of the following program execution? () B
public class Test ()
{
public static void Main (string[] args)
{
System.out.println ("" + ' a ' + 1);
}
}
A. 98
B. A1
C. 971
D. 197
7. What are the results of the following program execution? () B
int i = 100;
while (true)
{
If (i++ > 100)
Break
System.out.println (i);
}
A. 100
B. 101
C. 102
D. 103
8. What are the results of the following program execution? () C
int a=2;
Switch (a)
{
Case 1:
A+=1;
Break
Case 2:
a+=2;
Case 3:
a+=3;
Break
Case 4:
a+=4;
Break
Default
a=0;
}
System.out.println (a);
A. 5
B. 6
C. 7
D. 8
9. The following program operation results are () D
int a=3, b=1;
if (a==b)
System.out.println ("a=" +a);
A. a=1
B. a=3
C. Compilation errors
D. Normal operation but no output
10. After running the following program, the value of the a,b,c is correct: b
int a=1,b=2;
int c= (A+B>3?A++:++B);
A. a=2,b=3
B. a=1,b=3
C. a=1,b=2
D. c=2
11. Running result of the following program B
public class Demo
{
public static int Fun (int c)
{
return c+=2;
}
public static void Main (string[] args)
{
int Temp=fun (2);
SYSTEM.OUT.PRINTLN (temp);
}
}
A. 2
B. 4
C. 6
D. 8
12. The results of the following program, which is the correct B
int b=1;
while (++B<3)
System.out.println ("LOOP");
A. The program will enter the dead loop resulting in no output
B. Output Loop Once
C. Multiple loops are output
D. The program contains compilation errors
13. The following array definition error is () C
A. int [] arr ={23,45,65,78,89};
B. int [] arr=new int[10];
C. int [] Arr=new int[4]{3,4,5,6};
D. int [] arr={' a ', 23, 45, 6};
14. What are the results of the following program execution? () D
int x =1,y=1;
if (x++==2 & ++y==2)
{
x=7;
}
System.out.println ("x=" +x+ ", y=" +y);
A. X=1 y=2
B. x=7 Y=1
C. x=7 y=2
D. x=2 y=2
15. The following is not a basic data type is () D
A. int
B. Double
C. Long
D. int[]
16. Give the following code:
Boolean a = false;
Boolean B = true;
Boolean c= (A&&b) && (!b);
int result = (c = = false)? 1:2;
After execution, the value of C and result is (). A
A. False and 1
B. True and 2
C. True and 1
D. False and 2
17. Read the following code:
public class Test
{
public static void Main (String []args)
{
int f=12;
int i = 3;
System.out.println (f/i);
}
}
The program runs with a () result. C
A. 3
B. 3.0
C. 4
D. 4.0
18. What are the results of the following program execution? () C
Boolean b=true;
if (B=false)
{
System.out.println ("a");
}
else if (b)
{
System.out.println (b);
}
else if (!b)
{
System.out.println ("C");
}
Else
System.out.println ("D");
A. A
B. True
C. C
D. D
19. What are the results of the following program execution? () D
int x=2,y=3;
Switch (x)
{
Default
y++;
Case 3:
y++;
Case 4:
y++;
}
Sysetem.out.println ("y=" +y);
A. 3
B. 4
C. 5
D. 6
20. Results of the following program execution
for (int i=1;i<=10;i++)
{
if (i<5)
Continue
System.out.println ("Java Basic class");
}
Print several Java basic classes on the screen? () B
A. 5
B. 6
C. 7
D. 8
21. Read the following code snippet:
public class Demo
{
public static void Main (string[] args)
{
int[] arr = new int [10];
System.out.println (arr[1]);
}
}
The correct statement of execution is () C
A. Compile-time error will occur
B. Compile-time is correct and the runtime generates an error
C. Output 0
D. Output null
22. And the following code can be done the same option is () B
int i=1;
int sum=0;
while (i<=100)
{
if (i%2==0)
{
Sum=sum+i;
}
i++;
}
A. for (int x =1; x<=100;x++) {sum=sum+x;}
B. for (int x =0; x<=100;x+=2) {sum=sum+x;}
C. for (int x =1; x<=100;x+=2) {sum=sum+x;}
D. All the above-mentioned
23. Read the following code snippet:
public class Test
{
public static void Main (string[] args)
{
Char ch= ' C ';
Switch (CH)
{
Case ' a ':
System.out.print ("a");
Break
Case ' B ':
System.out.print ("AB");
Case ' C ':
System.out.print ("C");
Default
System.out.print ("D");
}
}
}
The result of the output is () D
A. A
B. b
C. C
D. cd
24. The following code output is () D
int i=0;
int sum=0;
while (i<=10)
{
i++;
if (i%2! = 0)
Continue
Sum+=i;
}
SYSTEM.OUT.PRINTLN (sum);
A. 55
B. 45
C. 35
D. 30
25. The statement in the following statement that performs the Jump function is () C
A. For statement
B. While statement
C. Continue statements
D. Switch statement
26. In a switch (expression) statement, the data type of expression cannot be () B
A. Double
B. Char
C. Byte
D. Short
27. Give the following code snippet:
if (x > 0) {System.out.println ("Hello.");}
else if (x >-3) {System.out.pirntln ("I am Tom.");}
else {System.out.println ("How is You?");}
Would you like to print the string "How is it?" The range of x is () C
A. x>0
B. x >-3
C. x <=-3
D. x <=0 & x >-3
28. In the following code, the line that will cause the compilation error is (). B
1) public class exercise{
2) public static void Main (String []args) {
3) float f=0.0;
4) f+=1.0;
5)}
6)}
A. Line 2nd
B. Line 3rd
C. Line 4th
D. Line 6th
29. The following code executes the result of () a
Class Demo
{
public static void Main (string[] args)
{
int num = max (43,34);
SYSTEM.OUT.PRINTLN (num);
}
public static int max (int a,int b)
{
Return a>b?a:b;
}
}
A. 43
B. 23
C. 77
D. 9
30. The result of the following program execution is () a
Class Demo
{
public static void Main (String [] args)
{
int a=10;
if (a++>10)
{
a=20;
}
System.out.println (a);
}
}
A. 11
B. 12
C. 20
D. 21
The following topics are multiple choices:
31. Which of the following are the valid identifiers () BCD
A. 2variable
B. variable2
C. what$
D. _3_
32. When the integer variable value is, only "message 2" is output BC
Switch (i)
{
Case 1:system.out.println ("Message1");
Case 2:
Case 3:system.out.println ("Message2");
Break
}
A. 1
B. 2
C. 3
D. 4
33. Which of the following statements can be compiled () ACD
A. float a= 1.34f;
B. float b=1.0;
C. float c=2f;
D. float d=20;
34. The following functions can be overloaded with the function int max (int A, int b, double c) () AB
A. Double max (int A, int b, double c)
b. void Max (int A, double c, int b)
C. int Max (double A, int b)
D. int max (int x, int y, double z)
35. The following array definition is correct? () AD
A. int arr[] = new INT[3];
B. int arr[] = new int[3]{1,2,3};
C. int [][]x = new int[][];
D. int[][] x = new int[2][];
36. Code reading, the following code to run the output of the result is () AC
Int[] arr={23,54,76,87};
for (inti=0;i<arr.length;i+=2)
{
System.out.println (Arr[i]);
}
A. 23
B. 54
C. 76
D. 87
37. The following statement is correct () AC
A. Byte, Short,char data type can be automatically converted to int
B. The float data type can be automatically converted to long.
C. The default decimal number in the Java language is double
D. Byte a=23; BYTE b=12; The result of A+b is byte type
38. Which of the following pieces of code will not compile error () AC
A. Boolean b=true;
Boolean b2=true;
if (B==B2) {System.out.println ("so True");}
B. int i=0; if (i) {System.out.println ("Hi");}
C. int i=1; int j=2; if (i==1| | j==2) System.out.println ("OK");
D. int i=1; int j=2; if (i==1 &| j==2) System.out.println ("OK");
39. The following description of the function is correct () AD
A. function is the encapsulation of functional code blocks
B. Function does not return a value when nothing is written àvoid
C. A function with no return value, cannot have a return statement
D. Functions can be without formal parameters
40. The following description of the loop is correct () AD
A. While loop first determines the loop condition and then performs a loop operation
B. While executes at least once
C. Do-while first cycle condition judgment, after the execution of the loop operation
D. Do-while cycle is performed at least once, followed by cyclic judgement
Intelligent Java Fundamentals Test