Basic Java Knowledge

Source: Internet
Author: User

1. Interfaces can only be modified with public

2 http: Hypertext Transfer Protocol Port 80

SMTP: Simple Mail Transfer Protocol port 25

FTP ssh 22

3 public int Amethod () {
static int i=0;
i++;
}

Compile error, cannot declare static variable in class

4 class Super {
Public Integer Getlenght () {return Newinteger (4);}
}

public class Sub extends Super {
Public long Getlenght () {return new Long (5);}
public static void Main (string[] args) {
Super Sooper = new super ();
Sub Sub = new sub ();
System.out.println (Sooper.getlenght (). toString () + "," +
Sub.getlenght (). toString ());
}
}

Compilation failed.---------Retiming cannot change the return type

5

classparent{String name= "Parent_name"; Static{System.out.println ("Parent_static"); }     PublicParent () {//TODO auto-generated Constructor stubSystem.out.println ("Parent_constructor"); }     Public voidmethod () {System.out.println ("Parent"); }     Public Static voidSmethod () {System.out.println ("Parent_1"); }}classChildextendsparent{String name= "Child_name"; Static{System.out.println ("Child_static"); }     PublicChild () {//TODO auto-generated Constructor stubSystem.out.println ("Child_constructor"); }     Public voidmethod () {System.out.println ("Child"); }     Public Static voidSmethod () {System.out.println ("Child_1"); }} Public classTEST5 { Public Static voidMain (string[] args) {child C=NewChild (); System.out.println ("---------------"); Parent P=NewParent (); System.out.println ("------------------");        P.method (); System.out.println ("--------------");        C.method (); System.out.println ("--------------"); Parent DDD=NewChild (); System.out.println ("--------------");        System.out.println (Ddd.name);    Ddd.method (); }}

Basic Java Knowledge

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.