7.8-Java basic knowledge test-summary of error-prone questions
- The command of the Java interpreter is (java) java HelloWorld class file to explain to the computer
- Java compiler command (javac)---->javac HelloWorld.java
- The development kit used by Java developers is (JDK)
- Programs developed in Java language can be run on any platform (and do not require JRE)
- All of the following are legal Java identifiers (B)
A.09stu teacher $money
B._salary post123 name
C.case abstract final
D.#ID list today
Analysis: A number cannot be placed at the beginning, B is correct, C identifier It cannot be a keyword, and D cannot use the # symbol - final float PI = 3.14f;
Analysis: Add F after the constant to indicate that it is of float type. If no F is added, the integer defaults to the int type, and the floating point number defaults to the double type.
public static void main(String[] args){
int x = 0;
Scanner sc = new Scanner(System.in);
x =sc.nextInt();
if(x--<5)
System.out.println(x);
else
System.out.println(x++);
}
After running, if you enter 5 from the keyboard, the output result is ()
A.3 、 B.4 、 C.5 、 D.6
Analysis: a++, ++a, where the value of a will increase by 1,
but the overall value of a++ remains unchanged, the overall value of ++a is +1,
so a–<5, incorrect, execute else, but the value of a The value of -1 becomes 4, and the value of a– is still 4