Java programmer face Question Day01

Source: Internet
Author: User
Tags float double

Java programmer face question day01

1.What is the difference between JDK and JRE ? What are their roles?

Jdkis aJavadeveloped toolkit that mainly contains a variety of class libraries and tools such asJavac/javaw/java, but it also includes an additionalJRE,two different virtual machines are available,JDKof thebinthe directory hasClientand theServertwo files under theJvm.dlldocuments;JREas a running environment, there is only oneClientunder theJvm.dllfile.

1. How do I compile and run the application using the JDK?

Javahome How to configure?

Go to the directory of the Java file

Compile statement:javac Helloworld.java

Execute statement:java Helloworld.java

3. What is the role of classpath?

function: The Java program is compiled and run when the search class, the actual storage is some directory and the address of the jar file, the point number represents the current path.

In fact,Java programs are compiled and run with a file called Rt.jar in the JRE folder , and then the Classpath the specified path.

4. How to dynamically specify a search path for a class for a Java program

-cp-classpath Command

JAVAC-CP Add path \jar file path own class file

JAVA-CP Add path \jar file path own class file

5. Compilation and operation features of the Java language

A class file is javac compiled into a class file, the file is a bytecode file, the file itself is not recognized, but the JVM It can be recognized thattheJVM loads these files and then converts those bytecode into machine code that can be executed for the computer, which is also the reason for cross-platform.

What is 6.JVM and how does it work?

The JVM is a software-simulated computer that has a very rigorous set of technical specifications and a basis for cross-platform dependencies when executing Java programs. There are processors, stacks, registers, and a corresponding instruction system. A java to run on the JVM is loaded, linked, and initialized by the JVM. The execution of a class is always initiated from the main method, and if an attempt is made to execute the class's binaries and the corresponding class information is not found, the class is loaded through class.forname . Then, the initialization of the class is performed on the initialization of the static initialization function and the static domain, which are declared in the class, and then linked and initialized. Then start executing the main method.

7. java why not delete statement for garbage collection?

java java c++ same as the program, each time the heap in-memory data delete No, not like writing c free drop. Because the garbage collection mechanism calls the system's GC finalize method for garbage collection, in addition finalize

8. Package Files with the jar command

8. directory structure, deployment, and configuration information for the Javaweb project

One of your own project levels:

. MyEclipse Empty Folder

What is 10.EJB?

Enterprise java Beans are part of Java EE and are suitable for distributed development, defining the session Bean entity Bean and a message-driven Bean.

Session Bean: The request to receive the client and implement the business logic, can be stateful, or can be stateless, each time the client requests, the container will select a sessionbean for the client service.

Entity Bean: A solid object that primarily implements the O/R Mapping and is responsible for mapping table records in the database to an in-memory entity Object

Message driven Bean: can only receive JMS messages sent by the client , and then processing, suitable for asynchronous development.

What are the variables and their scope in Java?

static variable modified by static, which belongs to the class itself, is initialized when the class is loaded and ends its life cycle as the class ends.

A member variable is an instance of a class that is an object of a class that is generated and initialized as the object is loaded and disappears as the object is garbage collected.

A local variable is a parameter that is defined inside a method or the method itself, and works in {} . Created with the invocation of the method and disappears as the method executes.

What are the two big data types for Java variables?

Basic data type:byte short int long float double char : Stores data with a smaller amount of data, stores 1 or more bytes of data, and saves the value of the data directly using binary binary.

Reference data type: An array of instances of the created object String ...

The address is stored.

wrapper classes for Java basic data types

There are certain applications: thelist set cannot store the basic data type, only the data of the wrapper type can be stored.

For example, to convert a base data type to a wrapper type:

(1) Int i = 5;

Integer NUM1 = integer.valueof (i);

(2) constructor Function:

Num2 = new Integer (i);

(3) in fact, because Java with auto-boxing function

The Integer num3 = 5;

This 5 can be automatically boxed into an Integer type directly.

The wrapper type is converted to the base data type:

Integer num = integer.valueof (100);

(1) Int.value () method:num.intvalue ();

(2) Assign the package type to the base type, automatically unpacking:Int res = num;

The correspondence between the basic data type and the wrapper type:

How do I understand boxing and unpacking in Java?

is the conversion between the base data type and the wrapper type (or the corresponding relationship between the 8 types, as shown in the table above), without having to manually type the conversion, which is done in the compilation phase.

An example:

Integer num = 10;

Sop (num++);

Understand these two lines of code:

The first step is to automatically box the base data type into an Integer wrapper type, and then automatically unpack the wrapper type to the base data type and then perform a self-increment operation.

What arethe links and differences between Java references and C + + pointers?

Contact: All points to a memory address, using a reference or a pointer to manipulate the data in memory.

Difference:

<1> Type: A reference to the value of the address of the data element, the location of the address, can be turned into a string to view, length do not care;C + + pointer is an Int type variable with address, The length is usually the word word of the computer.

<2> Memory: There is no entity when referencing the declaration, no space, that is defined, but no initialization, no space;C + + pointers if stated, but not used later, no memory is allocated. After you declare a pointer, either specify an existing address or assign an address to it.

<3> Initial value: The initial value of the referenced initial value of null,c++ is not fixed.

<4> calculation: The referenced value can not be calculated,C + + pointer is int, can be calculated , However, it may point to an address that is not part of your program and is dangerous for other programs.

<5> as a parameter:java 's method parameter is only a value, when used as a parameter, it is meaningless to exchange two reference parameters inside the function, the function just exchanges the copy of the parameter value, but it is meaningful to change the properties of a reference parameter within a function because the reference parameter's Copy The referenced object and reference parameter are the same object. the C + + pointer is used as a parameter to the function, which is actually the operation on the address referred to, which affects the address pointed to by the pointer.

describe the main method in Java ?

The main method is a Java program's entry function, which is a public, static, no return value, a method that accepts a String array parameter, whose parameters The args and execution parameters are one by one corresponding, defined in a class.

public class test{

public static void Main (string[] args) {

}}

Whatis the difference between the Equlas method and = = ?

Explanation:= = when used in the basic data type, will compare their actual values to compare two objects are not equal, when applied to the reference type of data, will be compared to the same address, that is, is not pointing to the same object, through the new A String () generates a new object separately.

The equal method is the java.lang.object method , and all java classes will have methods that can be overridden and rewritten by the programmer, Determine whether two objects are equal by their own defined method, and the default method and = = are the same. At the same time,java.lang.String is a special class that cannot be inherited, andtheequals method is used to compare the exact character sequence of a string. Returns true if the same .

What are the circular structures and their characteristics in 18.java?

While do-while for

Three mesh operator?

Expression 1? Expression 2: Expression 3

Expression 1 can simply return true/false return true to execute expression 2 , otherwise the execution of an expression 3

comments in 20.java?

Four types of annotations:

Line comment //

Block Comment /**/

Document Comment /** * /

Annotation ( note )

The document comments can enter the comment information into the Javadoc document, and the annotations go to the compilation layer and affect the results of the program.

Java programmer face Question Day01

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.