Java testing (1), Java testing (
Which of the following statements about the while and do-while loops are true?
In addition to the different formats, the functions of the two loops are identical. B and the do-while statement cannot communicate. The loop of the while statement executes the C do-while statement at least once and calculates the termination condition first, when the conditions are met, the Statement D or above in the loop body is not executed. Correct answer: D
Program System. out. println ("1 + 1 =" + 1 + 1); the output result is ()
A 1B 1 + 1 = 2 C 1 + 1 = 11 D 2 correct answer: C
The () method of the java. lang package compares two objects and returns true if they are equal.
A toString () B equasl () C compare () D or above are incorrect answer: B
The statement that cannot constitute a loop is ().
A for statement B while statement C switch statement D do while statement correct answer: C
System. out. println ("5" + 2); the output result should be ()
A 7 B 2C 52 D 5 correct answer: C
In the current java Implementation, each file after compilation is a file with the suffix ()
A java B class C doc D exe correct answer: B
Public class TT {
Public static void main (String [] args ){
Int a = 3;
If (true ){
A ++;
If (a> = 4 ){
Break;
}
}
System. out. println ();
}
}
Running result ();
A 3 B 4 C 5 D program errors correct answer: D
The statement that defines int I = 123; long j = 456; the following assignment is incorrect ().
A j = I; B j = (long) I; C I = (int) j; D I = j; correct answer: D
What content should a cycle contain?
A Initialization Part B loop body part C iteration part and termination Part D and above are all correct answers: D
System. out. println ("a + B =" + 3 + 4 );
The output result is
A "a + B = + 3 + 4" B a + B = 7 C a + B = 34 D a + B = + 3 + 4 correct answer: C
Break Statement ()
A only interrupts the inmost loop B only interrupts the cycle C of the outermost layer with the help of the label, can realize any outer loop interrupt D only interrupts the cycle of A certain layer correct answer: D
Which of the following loops will lead to an endless loop ()
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 ++) Correct answer: C
In java statements, operators & implementations
A logic or B logic is equal to C logic. Non-D logic. Correct answer: B.
Which of the following statements is true? int [] arr = new int [] {};
An error occurred in program A. Program B must be specified when the array is created. Program C must be specified when the array is created, when creating an array, you must specify the content and length. D. The program is correct. Answer: D.
I is known to be an integer variable. Which of the following statements about the unary operation ++ I and I ++ are true?
A ++ I operation will cause an error. B. Run the program with the same result in all circumstances. C. Run the program with different results in all circumstances. D. Add 1 to the value of variable I in all circumstances. answer: D
In Java, which does not belong to the integer type variable is ()
A double B long C intD byte correct answer:
Which of the following are the three-object (condition) operators:
A + B? : C & D | correct answer: B
Which of the following is not a valid identifier?
A x $ B @ abc123 C 1X d xyz correct answer: B
String [] strArr = new String [2]; what is the initial value of the String in the array?
A "0" B "null" C 0 D null correct answer: D
If x = 5 is set, then the results of y = x -- and y = -- x make y respectively.
A 5, 5 B 5, 6 C 5, 4 D 4, 4 correct answer: C
The value range of The byte variable is _______
A 0-65535 B-128-127 C-256-255 D 0-32767 correct answer: B
Which of the following statements defines the Array () of the five elements ()
A int [] a = {22, 23, 24, 25, 12}; B int a [] = new int (5); C int [5] array; D int [] arr; correct answer:
There is a two-dimensional array int [] [] arr = new int [2] [3]; The format for obtaining the length of an array with an index of 0 is
A arr [0]. length () B arr. length C arr [1]. length () D arr [0]. length correct answer: D
How to write the output character \ In System. out. println on the console?
A "\" B "\" C "/\" D "\/" correct answer: B
The java application named HelloWorld. Java is as follows:
Public class HelloWorld {
Public static void main (String args []) {
System. out. println ("Hello World! ");
}
}
Put this program under C: \ Test, and then in the command line window, enter the C: \ Test path and execute the following command: javac HelloWorld. java will get the () result.
A compilation error. B: The file HelloWorld. class is successfully compiled. C: The file helloworld. class is generated. D: The file helloworld. java cannot be found. Correct answer: B
Which of the following are the correct descriptions of the main method?
A public main (String args []) B public static void main (String args []) C private static void main (String args []) D void main () Correct answer: B
In the following expression, the first value used to access the array is ____
A intArray [1] B intArray.1 C intArray [0] D intArray.0 correct answer: C
Which of the following are not java keywords ______.
A for B if C true D else correct answer: C
Known: int [] a = new int [100]; which of the following array elements is invalid?
A a [0] B a [1] C a [99] D a [100] Correct answer: D
After the following statement is executed, the values of a, B, and c are ()
Int a = 2;
Int B = (a ++) * 3;
Int c = (++ a) * 3;
A 2, 6, 6 B 4, 9, 9 C 4, 6, 12 D 3, 9, 9 correct answer: C
How many digits does int data occupy?
A 32 B 16 C 22 D 18 correct answer:
In java, the result of the statement 37.2% 10 is
A 7.2 B 7 C 3 D 0.2 correct answer:
What types of elements can an array contain? _____________.
A int type B string type C array D or above can be correct answer: D
The command for compiling a java program is ___;
A java B javac correct answer: B
Which of the following statements is true:
A jar package is actually A zip Package B jar package can only contain. class file C can run the jar package using the java-jar command, but you need to specify the class in the main class D jar package (. class file) should also be placed in the corresponding folder with the package. Correct answer: ACD
Which operators does Java provide?
A Arithmetic Operator B bit operator C relational Operator D logical operator E conditional operator correct answer: ABCD
Which of the following statements are true?
A. JDK is A java Development Kit of JavaSE. B. java package name uses lowercase letters. C. java class name should use the camper method. D. java method. Name should use the camper method. Correct answer: ABD.
The following () is a keyword not used in Java
A const B goto C int D assert correct answer: AB
Which types of applications can be easily developed by the technologies directly provided in JDK?
A console/Terminal application B desktop application c bs architecture Internet Application d bs architecture enterprise application correct answer: AB
Which of the following statements are correct _________
A int I = 32; B float f = 45.32; C double d = 3.2; correct answer: AC
Which of the following statements is true?
A class can implement multiple interfaces. B A class can implement only one interface. C A class can implement multiple interfaces, but interfaces must be inherited. D. One class can only inherit one parent class. Correct answer: AD
String is a basic type.
Correct and correct answer: incorrect
The nextInt () method can convert the input to an integer. The nextInt () method is intelligent and does not throw an exception.
Correct and correct answer: incorrect
It is a trivial matter to name the packages, classes, methods, and parameters in the Code. Just get a name and the program can run.
Correct and correct answer: incorrect
Eclipse provides a debugging perspective for debugging.
Correct and incorrect answer: Correct
Int and double types are added. int type is automatically converted to double type.
Correct and incorrect answer: Correct
When "&" is used, if the first condition is false, the subsequent conditions will not be judged.
Correct and correct answer: incorrect
The difference between if/else and switch is that if/else is a boolean-value-based dual branch, and switch is a multi-branch based on integers, enumerations, and strings.
Correct and incorrect answer: Correct
You can add any element to the array.
Correct and correct answer: incorrect
When "|" is used, if the first condition is true, the subsequent conditions are no longer judged ()
Correct and incorrect answer: Correct
During Java code debugging, you can stop at the breakpoint and then control the single-step execution of the program.
Correct and incorrect answer: Correct
In Java, float and double can only represent the approximate values of decimal places. For example, the result of float 0.1 + 0.8 is not equal to 0.9. In comparison, double is only a little more accurate than float.
Correct and incorrect answers: correct: ----------------------------------------- lists the five keywords that have been known: class public static void return if else while new break continue; Java annotations include ____, _____ and ______, multi-line comments, and single line comments. note ---------------------------------------- the Java program structure can be divided into _______, ________, and ________ sequence structures, selection (Branch) structure and cyclic structure ----------------------------------------------------- the identifiers in Java are composed of letters, numbers, underscores (_), and underscores ($ ). It cannot start with a number. It cannot be a keyword in Java (some languages also call it a reserved word) -------------------------------------- double a = 7.5, int B = 5, then the result of a % B = 2.5 ------------------------------------------------ true & false & true is ___ false ___. -------------------------------------------------- Write all the basic data types in java and describe the number of bytes occupied by each type? Byte (1) short (2) int (4) long (8) float (4) doouble (8) boolean (1) char (2) ----------------------------------------------------- what should I pay attention to when writing the basic data type conversion? When int and float are converted, small data types can be directly converted to large data types, a large range of data types must be strongly converted to convert int and char to a small range. char can be directly converted to int. If it is a Chinese character, the Unicode encoding table will be queried, if not, the ASCII code table will be queried. The conversion from int to char is the same, but the forced type conversion is required: ------------------------------------------------ what is a java identifier and the role of the identifier; java identifiers are used to name classes, objects, methods, variables, interfaces, and custom data types. They can be concise and clear. In java, all class names, method names, array names, attribute names, and variable names... All are called java identifiers; -------------------------------------------------------- what is the purpose of environment variable configuration? By configuring environment variables, we can directly use javac and java in the command line regardless of the directory, instead of finding -------------------------------------------------------------------------- the difference between break and continue in the bin directory of the JDK installation directory. 1. break can be used in both switch and loop. continue can only be used in loop. 2. in the loop, break indicates that the loop is ended, and continue indicates that the loop is exceeded and enters the next loop; -------------------------------------------------------- differences between I ++ and I ++: What is the statement used to write a package after the first operation and then the auto-increment ++ I operation? What java package does not need to be imported? Import package path. Class Name; Content in the lang Package, do not import ----------------------------------------------------------- JDK, JRE, what are jvm respectively? What is the connection? JDK is a java development environment, JRE is a java Runtime Environment, and JVM is a java virtual machine. when JDK is installed, the installation program will install JRE. JVM obtains a Random number ranging from 345 to 564 in the JRE, and writes the program Random ran = new Random (); int a = ran. nextInt (564-345 + 1) + 345; ------------------------------------------------------------ how to understand the characteristics of while and? The while loop is generally used to know the number of cycles -------------------------------------------------------------------- when the number of cycles is unknown. Compile a HelloWorld program public class TTT {public static void main) {System. out. println ("Hello World ");}}-----------------------------------------------------------------
English translation:
Exception in thread "main" java. lang. ArithmeticException:/by zero
At com. zhiyou100.MyApp. main (MyApp. java: 26)
An exception occurs in the main thread. The exception type is ArithmeticException. The arithmetic operation is abnormal except for line 26th of the MyApp. java file in the main method of the com. zhiyou100.MyApp class.
-----------------------------------------------------------------
Variable declaration method;
Data type variable name; variable name = variable value;
------------------------------------------------------------------
Brief description of the identifier naming rules
1. See the name and meaning 2. Size of the first letter of the class name, starting from the second word, the first letter of each word in upper case; the first letter of other names in lower case, starting from the second word, the first letter of each word in upper case
-----------------------------------------------------------------------
Java. lang. ArrayIndexOutOfBoundsException
This is caused by an array index out-of-bounds exception. If the index exceeds the maximum index of the array, the search code finds the corresponding operation and modifies it.
-------------------------------------------------------------------
How can java be compiled and run everywhere?
Because the java program runs on JVM, we only need to install different virtual machines on different operating systems. Some virtual machines execute the interpretation of the file and execute it as a machine code.
--------------------------------------------------------------------
Create an Account class with id: Account number (long integer), password: Account password, name: Real name, personId: id card number string type, email: customer's email address, balance: account balance. method: deposit method. The parameter is the double-type amount. withdraw: the withdrawal method. The parameter is the double-type amount. constructor: with and without parameters. The constructor is used to set necessary attributes.
Package com. zhiyou. day_03_05; public class Account {String name; double balance; int username; int password; // check whether the Account password matches the public boolean isPiPei (int username, int password) {if (username = this. username & password = this. password) {return true;} else {return false;} // withdraw public void quKuang (double a) {if (a> balance) {System. out. println ("insufficient balance, Please re-enter");} else {balance-= a; System. out. println (name + "get" + a + ", and" + balance) ;}// deposit public void cunKuang (double a) {balance + = a; System. out. println (name + "saved" + a + ", and" + balance );}}