What modifiers are allowed for methods in an Interface?
Ans- Only public and abstract modifiers are allowed for methods in interfaces.
What is a local, member and a class variable?
Ans- Variables declared within a method are "local" variables.
Variables declared within the class i.e not within any methods are "member" variables (global variables).
Variables declared within the class i.e not within any methods and are defined as "static" are class
variables.
Can an Interface have an inner class?
Ans- Yes.
public interface abc {
static int i=0;
void dd();
class a1 {
a1() {
int j;
System.out.println("in interfia");
};
public static void main(String a1[]) {
System.out.println("in interfia"); } } }
Can we define private and protected modifiers for variables in interfaces?
Ans- No
Can there be an abstract class with no abstract methods in it?
Ans- Yes
Ans- Only public and abstract modifiers are allowed for methods in interfaces.
What is a local, member and a class variable?
Ans- Variables declared within a method are "local" variables.
Variables declared within the class i.e not within any methods are "member" variables (global variables).
Variables declared within the class i.e not within any methods and are defined as "static" are class
variables.
Can an Interface have an inner class?
Ans- Yes.
public interface abc {
static int i=0;
void dd();
class a1 {
a1() {
int j;
System.out.println("in interfia");
};
public static void main(String a1[]) {
System.out.println("in interfia"); } } }
Can we define private and protected modifiers for variables in interfaces?
Ans- No
Can there be an abstract class with no abstract methods in it?
Ans- Yes
0 comments:
Post a Comment