The basic classroom problem of Java language

Source: Internet
Author: User

1. Why is Java specified as the main entry point of the program is static?

Because static methods do not have to establish objects, the main function of the program must be referenced.

2. Scope of variables

public class Fun1 {
private static int v=1;
public static void Main (string[] args) {
int v=2;
System.out.println (v);
}
}

Result is 2

3. The reason why the double type is inaccurate

is related to the binary inside the computer

4.

Package fun;

public class Fun2 {
public static void Main (String args[]) {
int x=100;
int y=200;
System.out.println ("x+y=" +x+y);
System.out.println (x+y+ "=x+y");
}

}

Results

x+y=100200
300=x+y

Related to the order of operators, the most recent plus sign is the assignment.

The basic classroom problem of Java language

Related Article

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.