COMPILER DESIGN

ADVANCED TOPICS IN COMPILER DESIGN

CODE GENERATION FOR OBJECT ORIENTED LANGUAGES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What modifiers are allowed for methods in an Interface?
A
Private
B
Protected
C
Abstract
D
None of the above
Explanation: 

Detailed explanation-1: -Answer: Only public and abstract modifiers are allowed for methods in an interfaces.

Detailed explanation-2: -An abstract method can only set a visibility modifier, one of public or protected. That is, an abstract method cannot add static or final modifier to the declaration.

Detailed explanation-3: -Only public and abstract modifiers are allowed for methods in interfaces.

Detailed explanation-4: -Only a “public” access modifier is allowed.

Detailed explanation-5: -Abstract classes methods can have access modifiers as public, private, protected, static but interface methods are implicitly public and abstract, we can’t use any other access modifiers with interface methods.

There is 1 question to complete.