Java Programming - Declarations and Access Control - Discussion
Discussion Forum : Declarations and Access Control - General Questions (Q.No. 18)
18.
Which is a valid declaration within an interface?
Answer: Option
Explanation:
(A) is valid interface declarations.
(B) and (C) are incorrect because interface variables cannot be either protected or transient. (D) is incorrect because interface methods cannot be final or static.
Discussion:
11 comments Page 1 of 2.
Alok s said:
6 years ago
Inside interface any variable you declare.
i.e
By default public static final ..and if u declare any methods it also public and Abstract.
Eg- interface Inf
{
Public static final int a=6;//variable decl
Public abstract m1 ();//decl of method
}
i.e
By default public static final ..and if u declare any methods it also public and Abstract.
Eg- interface Inf
{
Public static final int a=6;//variable decl
Public abstract m1 ();//decl of method
}
Mitesh Jain(Ujjain) said:
1 decade ago
The answer(A) is right, because data member of interface can be static, final and public. Yes, Interface and classes can't be static. And interface's methods also can't be static. But data member is possible.
Vijay said:
8 years ago
Interface by default all the variables are " PUBLIC STATIC FINAL " and all the methods are " PUBLIC and ABSTRACT ".
I hope it is clear now.
I hope it is clear now.
Bharath said:
1 decade ago
public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifiers?
Pawan patidar said:
1 decade ago
public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifiers?
Google said:
1 decade ago
Public static short stop=23; is given as correct answer but how come its possible, interface does not accept static modifier?
Vishnu kumar ravula said:
10 years ago
How can you access a static variable in interface using the its name without reference ?
Prabhat Kumar said:
1 decade ago
Option A is also wrong, because static methods r not allowed in interfaces.
Nirali khunt said:
1 decade ago
Interface can not initialize the variable so it is not possible.
Hariom singh said:
1 decade ago
What is the working of join method in threading ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers