logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • What is the difference between an Interface and an Abstract class ?


  • Correct Answer
  • 1Main difference is methods of a Java interface are implicitly abstract and cannot have implementations A Java abstract class can have instance methods that implements a default behavior 2Variables declared in a Java interface is by default final An abstract class may contain non-final variables 3Members of a Java interface are public by default A Java abstract class can have the usual flavors of class members like private, protected, etc 4Java interface should be implemented using keyword ?implements?; A Java abstract class should be extended using keyword ?extends? 5An interface can extend another Java interface only, an abstract class can extend another Java class and implement multiple Java interfaces 6A Java class can implement multiple interfaces but it can extend only one abstract class 7Interface is absolutely abstract and cannot be instantiated; A Java abstract class also cannot be instantiated, but can be invoked if a main() exists 8In comparison with java abstract classes, java interfaces are slow as it requires extra indirection 


  • Technology problems


    Search Results


    • 1. Can you access non static variable in static context ?
    • Discuss
    • 2. What is autoboxing and unboxing ?
    • Discuss
    • 3. What is the output of this program ? class main_arguments { public static void main(String [ ] args) { String [][] argument = new String[2][2]; int x; argument[0] = args; x = argument[0].length; for (int y = 0; y < x; y++) System.out.print(" " + argument[0][y]); } }

    • Options
    • A. 1 1
    • B. 1 0
    • C. 1 0 3
    • D. 1 2 3
    • Discuss
    • 4. What?s the difference between Enumeration and Iterator interfaces ?
    • Discuss
    • 5. What do you know about the big-O notation and can you give some examples with respect to different data structures ?
    • Discuss
    • 6. Which of the following statements are equal for a variable declared in the interface ? 1. int X=10 2. public int X=10 3. public static final int X=10

    • Options
    • A. Only 1 and 2 are equal
    • B. Only 2 and 3 are equal
    • C. All are unequal
    • D. All are equal
    • Discuss
    • 7. Inside an interface when should the variables be initialized?

    • Options
    • A. Globally
    • B. Whenever required
    • C. Inside a function
    • D. During the time of declaration
    • Discuss
    • 8. Which of the following method declarations are allowed inside interface?

    • Options
    • A. public void m1()
    • B. private void m1()
    • C. protected void m1()
    • D. abstract public void m1()
    • Discuss
    • 9. Why interface method is always public?
    • Discuss
    • 10. Which among the following is a scope resolution operator?

    • Options
    • A. :
    • B. ::
    • C. :?
    • D. None
    • Discuss


    Comments

    There are no comments.

Enter a new Comment