April 28, 2013

Core Java Interview Questions And Answers

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

0 comments:

Post a Comment

  • Blogger news

    This Blog Contains All Topics Related To Internet, Website Help, Interview Questions, News, Results From Various Resources, Visit Daily For More Interesting And Famous Topics.
  • Random Post

  • About

    We Provide All Information Which you Needed. We Maintain This Blog Very Carefully, If You Find Any Mistake or Any Suggestions Then Please Let Us Know, You Can Contact Us By Comments, On FB Page Or On Google+ Page. ~ Thank You