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