Java Interview-Java Overview and Basics (1)

Source: Internet
Author: User

1, what is programming?

Programming is the process of having a computer write program code in a programming language to solve a problem and ultimately get results.

In order for the computer to understand people's intentions, mankind must be able to solve the problem of the ideas, methods, and means through the computer can understand the form of telling the computer, so that the computer can be based on the instructions of the person to work one step at a certain task. The process of communication between people and computers is programming.

2. Java language overview, history, features


is a high-level language introduced by Sun (Stanforduniversity Network, Stanford University Internet Company) in 1995.

is an Internet-facing programming language.
As Java technology continues to mature in the web, it has become the preferred development language for Web applications.
is easy to learn, completely object-oriented, safe and reliable, platform-independent programming language.


java5.0 the following three technical frameworks

ee (Java 2 Platform Enterprise Edition) Enterprise Edition

Called Java EE after the jdk5.0 version, is a set of solutions for developing applications in enterprise environments. The technologies included in the system, such as servletjsp, are mainly for Web application development. It is one of the main learning contents of the Intelligence podcast job and training camp.

J2SE (Java 2 Platform standard Edition ) Standard Edition

After the jdk5.0 version is called Javase, which is the main learning content in the Java Foundation Stage, is also the basis of Java, regardless of whether to engage in Android development or the development of the Internet of Things + cloud computing, etc. is based on the JSE Foundation, so this technology is Java's most core technology, It is the main course content of the basic course of Intelligence podcast.

J2ME (Java 2 Platform Micro Edition) Small version

After the jdk5.0 version is called the Javame, this technology is more used in some electronic products embedded development, previously used in mobile phone development is also more, but with the development of smartphones, now mobile applications (such as Android program) development has no longer use the technology.

3, what is cross-platform? What is the principle? Jvm

The so-called cross-platform, refers to the Java language program written, once compiled, can be run on multiple system platforms.

Implementation principle: Java program is running on the system platform through the Java Virtual machine, as long as the system can install the corresponding Java virtual machine, the system can run Java programs. (Note that it is not possible to run on all platforms, the key is whether the platform can install the corresponding virtual machine).

My summary: Java The program is able to run across platforms because it does not run directly on any underlying platform, but where it needs to be run, like the Windows platform prepare your own Java in advance. platform, and that's just the installation and configuration of a software!

4. What is the difference between JRE and JDK?

JRE: (Java Runtime Environment),Java Runtime Environment . including Java virtual machines (JVM Java) and the core class libraries required by Java programs, if you want to run a well-developed Java program, you only need to install the JRE on your computer.

JDK: (Java Development Kit Java) Development Kit . The JDK is available to Java developers, which includes Java development tools and the JRE. So with the JDK installed, you don't have to install the JRE separately.

One of the development tools: Compilation tool (Javac.exe) Packaging Tools (Jar.exe) wait

In simple terms: Java programs developed using the JDK are delivered to the JRE to run.

My summary: Must be proficient in memory, core class library, development tools!

5. Java Virtual Machine JVM

Java Virtual Machine, referred to as the JVM;

It is an abstract computer that runs all Java programs, is the Java language's operating environment, it is one of the most attractive features of Java, the JVM reads and processes the compiled platform-independent bytecode (class) files.

The Java compiler produces a class file for the JVM and is therefore platform-independent.

The Java interpreter is responsible for running the JVM's code on a specific platform.

Java virtual machines are not cross-platform.

6. Java Program Operation mechanism

Compile: javac filename. file suffix name

Run: Java class name

My summary: The composition of the Java program: Java source files, bytecode files.

7. Where to learn Java attention

The Java language is strictly case-sensitive in spelling;

In a Java source file, you can define multiple Java classes, but at most one of these classes is defined as a public class;

if public is included in the source file class, the source file must and the public class with the same name;

When a source file contains n Java classes, an n-bit bytecode file is generated after compilation, that is, each class generates a separate class file, and the byte-code file name and

Its corresponding class name is the same;

My summary: A Java source file defines only one class, and different classes use different source file definitions;

Define the individually defined classes in each source file as public;

Keep the main file name of the Java source file consistent with the class name in the source file;

8. Java Syntax format

Any language has its own grammatical rules, Java is the same, since it is the rule, then know how to use it.

The code is defined in the class, the class is defined by class, and the public class and class are distinguished.

The code is strictly case-sensitive, such as main and main are not the same;

Identifiers and keywords in Java;

Comments

The function of the Main method:

Entrance to the program

Guarantee The independent operation of the program

Called by the JVM

9. Code Comment: Single line//, Multiline/* * *, document comment/** */

1. Single-line comment//:

All characters after the end of the bank are ignored by the compiler;

2. Multiline comment/* */:

*/* All characters between/* are ignored by the compiler

3. Documentation Comments/** */:

All characters between/** * * are ignored by the compiler and Java is special (for generating documents);

My summary: MultiRow and document annotations are not nested.

10. Identifiers in Java

It can be simply understood as a name in a Java program to enhance the readability of the customization. For example: Class name, method name, variable name, and so on.

Naming rules:

(1) consists of letters, numbers, underscores, and $, and cannot begin with a number

Note: The letters here can also be Chinese, Japanese, etc.;

(2) Case sensitive

(3) Do not use keywords and reserved words in Java

(4) Do not use the class name inside the Java API as your own.

11. Constants and Variables in Java

The concept of variables:

Occupy a storage area in memory;

The region has its own name (variable name) and type (data type);

The data of the region can be changed continuously within the same type;

Why do you define variables:

Used for constant storage of the same type of constant and can be reused;

Use variables Note:

Scope of the variable, initialize the value

To define the format of a variable: t

Data Type Variable name = initialization value;

Note: The format is fixed, remember the format, status quo.

Scope of Action: Defines the end of the code block that defines it;

Multiple local variable naming conflicts are not allowed in the same scope

12. Java member variables and local variables

Local variables: Variables that are not declared inside the body brackets of the class;

The value must be initialized before local variables are used;

Local variables do not have default initialization values;

The scope of a local variable is the end of the code block from the beginning of the definition to its definition;

Member variables: In the body of the method, variables declared in the class, also known as field or global variables; (there is no global variable in Java, because Java is an object-oriented language, all variables are class members)

The scope of the member variable is the entire class;

My summary: Notice the difference between a member variable and a local variable


Package Reviewdemo;

public class Demo2 {
public static void Main (string[] args) {
int i;
System.out.println (i);
}
}

Note: The local variable is not initialized before the call, so the compile time will be error!


Package Reviewdemo;

public class Demo2 {
static int i;
public static void Main (String[]args) {
System.out.println (i);
}
}

Note: At this point I is a global variable, uninitialized will be given the default initialization value! The program is correct!

My summary:

a local variable is a variable that is defined in a method,,, The variable cannot be accessed by this method ....
member variables are defined in the class,,,, and variables that can be accessed in the member methods of the class:

Java Interview-Java Overview and Basics (1)

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.