This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com</groupId> | |
<artifactId>restapi</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<packaging>jar</packaging> | |
<name>restapi</name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class StartApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(StartApplication.class, args); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class G extends G1 { | |
int x = 100; | |
public void display() { | |
System.out.println(“Subclass x value: “ + x); // prints 100 | |
System.out.println(“Super class x value: “ + super.x); // prints 10 | |
System.out.println(“Sum of x values: “ + (x + super.x)); // prints 110 | |
super.display(); // calling super class (G1) display() | |
System.out.println(“From subclass”); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class F implements InterfaceB { | |
public void m1() { | |
//super.m1();//This is NOT valid. | |
//InterfaceA.super.hello(); //This is NOT valid because F does not implement InterfaceA. | |
InterfaceB.super.m1(); //This is valid. | |
} | |
} | |
interface InterfaceA { | |
default void m1() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class H extends H1 { | |
public H() { | |
super(50); | |
System.out.println(“From H constructor”); | |
} | |
public static void main(String args[]) { | |
H objectH = new H(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class C implements I1, I2 { | |
public void m1() {} | |
public static void main(String… args) { | |
C tc = new C(); | |
System.out.println(( ( I1) tc).VALUE); | |
} | |
} | |
interface I1 { | |
int VALUE = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class D implements Interface2 { | |
public static void main (String… args) { | |
Interface1 acct = new D(); | |
System.out.println(acct.getId()); | |
} | |
public String getId() { | |
return “1111”; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class D implements Interface1, Interface2 { | |
public String getId() { | |
return “1111”; | |
} | |
} | |
interface Interface1 { | |
public default String getId() { | |
return “0000”; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class E implements Interf1 { | |
public String getId() { | |
return “E: get Id”; | |
} | |
public String getOtherId() { | |
return “E: get Other Id”; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class A { | |
static { System.out.println(“A Loaded”); } | |
public static void main(String[] args) { | |
System.out.println(“A should have been loaded”); | |
A1 a1 = null; | |
System.out.println(“A1 should not have been loaded”); | |
System.out.println(a1.i); | |
} |
OlderNewer