The scopes are public and just interface [Which means default ]
(no private, protected )
Example :
package OverridingMethods;
(1A) [public] interface interfaceOverrideMethods {
or just
(2a) interface interfaceOverrideMethods {
void overriddenMethod1();
void overriddenMethod2();
}
(2b)
In the case of ClassImplemtingInterfacefromAnotherPackage has to be in the same package
package OverridingInterfacesFromAnotherPackage;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
(1B)
package OverridingMethods;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
Is Correct.
(1C)
package OverridingInterfacesFromAnotherPackage;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
Is also Correct.
(no private, protected )
Example :
package OverridingMethods;
(1A) [public] interface interfaceOverrideMethods {
or just
(2a) interface interfaceOverrideMethods {
void overriddenMethod1();
void overriddenMethod2();
}
(2b)
In the case of ClassImplemtingInterfacefromAnotherPackage has to be in the same package
package OverridingInterfacesFromAnotherPackage;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
(1B)
package OverridingMethods;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
Is Correct.
(1C)
package OverridingInterfacesFromAnotherPackage;
import OverridingMethods.*;
public class ClassImplemtingInterfacefromAnotherPackage implements interfaceOverrideMethods{
public void overriddenMethod1() {
}
public void overriddenMethod2() {
}
}
Is also Correct.
No comments:
Post a Comment