Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the questions that are easy to step on in the introduction to Java?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "Java entry easy to step on pit question and answer questions". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

1, Java basic type

The following are Java basic data types ()

A.String

B.byte

C.char

D.Array

Java basic data types are divided into three types, numerical type, character type, Boolean type

Numerical type:

integer: byte, short, int, long

Float: double, float

Character type: char

Boolean: boolean

Array String is a reference data type, select BC

2. Java wrapper class

The following is Java wrapper class ()

A.String

B.Long

C.Character

D.Short

Java wrapper class is the class type corresponding to the basic type, the basic type is eight basic data types, so String does not belong to Java wrapper class. Select BCD

3, Java compilation

Which of the following statements is correct ( )

Java programs are compiled to generate machine code.

Java programs are compiled to generate byte code.

C.Java programs compile using the command javac run using the java command

D. None of the above is correct.

Java compiled bytecode file, Java program compiled using the command javac run using java command select BC

4,JDK,JVM,JRE

The following statements about JDK, JRE and JVM are correct: ()

A.JDK is a Java development kit, including Java Runtime Environment JRE (Java Runtime Envirnment), a bunch of Java tools (javac/java/jdb, etc.) and Java basic class libraries (Java API including rt.jar)

B.JRE is an indispensable runtime environment for running programs written in Java language. It is also through it that Java developers can publish their programs to users and let them use them.

C.JVM is the core part of the whole Java implementation, all Java programs will first be compiled into.class class files, which can be executed on the virtual machine. That is to say, class does not directly correspond to the operating system of the machine, but indirectly interacts with the operating system through the virtual machine, and the virtual machine interprets the program to the local system for execution.

D.JDK contains JRE,JRE also contains JVM

JDK(Java Development Kit) is a software development kit (SDK) for the Java language. There is a jre directory under the JDK installation directory, which has two folders bin and lib, where you can think of bin as jvm, lib as the class library required for jvm work, and jvm and lib together are called jre.

JRE (Java Runtime Environment) contains JVM standard implementations and Java core libraries. JRE is a Java runtime environment, not a development environment, so it does not contain any development tools (such as compilers and debuggers)

JVM is an abbreviation for Java Virtual Machine, JVM is a specification for computing devices, it is a fictitious computer, is realized by simulating various computer functions on an actual computer.

ABCD is correct.

5, type conversion

Basic data types can be converted to each other arbitrarily ()

A. Yes

B. wrong

boolean is also a primitive data type, but it cannot be converted to other types.

6, escape character

The escape character for a newline character in Java is: ()

A.\ n

B.\ f

C. 'n'

D.\ dd

choose A

7, identifier

In Java, the following identifiers are illegal:

A.new

B.$ Usdollars

C.1234

D.car.taxi

Java identifiers consist of numbers, letters and underscores (_), dollar signs ($) or yuan signs (¥). In Java, it is case-sensitive and requires that the first digit not be a number. Most importantly, Java keywords cannot be used as Java identifiers. New is a keyword. Select ACD

8, type conversion

What are the values of variables a and b after forced type conversion ()

short a =128; byte b =(byte) a;

A.128 127

B.128 - 128

C.128 128

D. Compilation errors

Java as a strongly typed programming language, when different types of variables assigned to each other, there will be strict validation. Let's start with the following code scenarios:

int and long/double mutually assign

int a = 10; long b = 20; a = b; //Compilation error, indicating possible loss of precision. b = a; //compiled by. int a = 10; double b = 1.0; a = b; //Compilation error, indicating possible loss of precision. b = a; //compiled by.

int can be assigned to long, but long cannot be assigned to int.

Double represents a larger range, and int can be assigned to double, but double cannot be assigned to int.

Conclusion: Assignment between variables of different numeric types means that a type with a smaller range can be implicitly converted to a type with a larger range, and vice versa.

128 is assigned to a,a=128,byte is one byte, size range-128-127, so b=-128

select B

9, assignment symbol

Which of the following is NOT an assignment symbol ( )

A.+=

B.>: The rightmost position is not needed, and the leftmost position is filled with 0.

int a = 0xffffffff; System.out.printf("%x\n", a >>> 1);

Output:

//Run results (note that they are printed in hexadecimal)

7fffffff

There is no unsigned left shift, choose C

10, print a string

If you want to print a string, you need to output the result: \"hello\", which of the following ways can output correctly: ( )

A.System.out.println("\\\"hello\\\"");

B.System.out.println("\\"hello\\"");

C.System.out.println("/\"hello/\"");

\\means print a\,\'means print a', so choose A

"Java entry easy to step on the pit of the question-and-answer questions what" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 267

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report