What is the default modifier in Interface?

Answer Posted / raj kumar sav

All of the methods in an interface are implicitly abstract.
Every method declaration in an interface specifies the
formal parameters and return type of the method, but it
does not include an implementation of the method.

All of the variables in an interface are implicitly static
and final.

Interface Modifiers
The keywords public and abstract can appear as modifiers at
the beginning of an interface declaration. In this
situation, these modifiers have the following meanings:


public

If an interface is declared public, it can be referenced by
any class or interface. If the public modifier is not used,
however, the interface can only be referenced by classes
and interfaces in the same package. A single source file,
or compilation unit, can only declare one public class or
interface (see Compilation Units for an exception to this
rule).


abstract

An interface is implicitly abstract; so all of the methods
in an interface are implicitly abstract. Including the
abstract modifier in an interface declaration is permitted,
but it does not change the meaning of the interface
declaration.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do singleton patterns work?

513


What are the differences between getting and load method?

538


When is the finalize() called? What is the purpose of finalization?

577


What is tostring () method?

538


What is the argument in java?

490






Can we restart a dead thread in java?

546


Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?

588


What do you mean by ternary operator in java?

554


What is stringbuffer in java?

539


What are the access modifiers in java?

584


Why strings in java are called as immutable?

589


What is a locale?

687


Can you declare an interface method static?

578


Say you want to store the information about a number of pets in an array. Typical information that you could store for each pet (where relevant) would be • Breed of animal • Animal's name • Its birth date • Its sex • Whether it has been sterilised or not • When it is due for its next inoculation • When it last had its wings clipped For each type of pet (eg. dog, cat or bird) you would typically define a class to hold the relevant data. Note: You do not need to implement these classes. Just answer the following questions. 3.1.1 What would be the advantage of creating a superclass (eg. Pet) and declaring an array of Pet objects over simply using an array of Objects, storing each of the instances of the different pet classes (eg. Dog, Cat or Bird) in it? 3.1.2 Would you define Pet as a class or as an interface? Why? (2) (2)

1343


What are the methods to rectify ambiguities in the interfaces in JAVA?

582