Welcome Guest | Sign in | Register

Home > Java Programming > Interface > Questions and Answers

01. which two are true?
A. An interface can implement another interface.

a class can implement more than one interface.
B. a class can implement more than one interface.

every class can implement at least one interface.
C. An interface can implement another interface.

every class can implement at least one interface.

D. a class can implement more than one interface.

many class can implement same interface.

Answer and Explanation

Answer: a class can implement more than one interface.

many class can implement same interface.

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. Interface writeable {}

Interface Erasable{}

Which three are valid?
A. a) Public class pencile extends writeable{}

c) Public interface pencile extends writeable{}

e) Public class pencile implements writeable, erasable{}
B. b) Public class pencile implements writeable{}

c) Public interface pencile extends writeable{}

e) Public class pencile implements writeable, erasable{}
C. a) Public class pencile extends writeable{}

c) Public interface pencile extends writeable{}

d) Public interface pencile implements writeable{}
D. c) Public interface pencile extends writeable{}

d) Public interface pencile implements writeable{}

e) Public class pencile implements writeable, erasable{}

Answer and Explanation

Answer: b) Public class pencile implements writeable{}

c) Public interface pencile extends writeable{}

e) Public class pencile implements writeable, erasable{}

Explanation:
a class can not extend interface ,it can only implement.So ans a) is not correct
An interface can extend another interface it shouldn’t implement another interface so ans d) is also wrong rest is correct 

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. Interface pet{
Void eat();
}

Class dog implements pet{
Public void eat(){}
}

Class Beagle extends dog{
Public void eat(){}
}

Which of the following demonstrate the”program to an interface ” principle?
A. class petfood{
public void go(Pet p){
p.eat();}}
B. class petfood{
public void go(dog p){
p.eat();}}
C. class petfood{
public void go(Beagle p){
p.eat();}}
D. class petfood extends pet {
public void go(Petfood p){
p.eat();}}

Answer and Explanation

Answer: class petfood{
public void go(Pet p){
p.eat();}}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. interface A{}

Interface B{
Void b(); }

Interface C{
Public void c();
}

abstract class D implements A,B,C{}



class E extends D{
void b(){}
public void c(){}
}
A. Code compiles without error B. Compile time error
C. Runtime error D. None of the above

Answer and Explanation

Answer: Compile time error

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. which is the valid definition of an interface called transportable given another valid interface moveable?
A. class moveable extends transportable { } B. class moveable implements transportable{}
C. interface transportable extends moveable{ } D. interface transportable implements moveable{ }

Answer and Explanation

Answer: interface transportable extends moveable{ }

Explanation:
an interface can extend another interface , an interface cannot implement another interface. And a class cannot extend an interface. So and is c).

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. Interface A{}
Interface B{}
Interface C extends A, B{}

What will happen if I compile above code?
A. compile time error B. run time error
C. Can not possible D. none of the above

Answer and Explanation

Answer: none of the above

Explanation:
an interface can extend multiple interface , but it can not implement multiple interface, only a class can implement multiple interface
So ans is d)

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. interface moveable{
Void move();
Void stop();
}

Which is valid?
A. Public class bicycle implements moveable{
Public void move(){}
}
B. Public class bicycle implements moveable{
void move(){}
void stop(){}
}
C. Public class bicycle extends moveable{
Public void move(){}
Public void stop(){}
}
D. Public class bicycle implements moveable{
Public void move(){}
Public void stop(){}
}

Answer and Explanation

Answer: Public class bicycle implements moveable{
Public void move(){}
Public void stop(){}
}

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. which three can be included in an interface declaration?
A. void showmessage();
public void showmessage();
private void showmessage();
B. public void showmessage();
static void showmessage();
abstract void showmessage();
C. void showmessage();
public void showmessage();
abstract void showmessage();
D. static void showmessage();
private void showmessage();
abstract void showmessage();

Answer and Explanation

Answer: void showmessage();
public void showmessage();
abstract void showmessage();

Explanation:
all the methods in an interface are by default public abstract, even if you don’t specify by default it will be public abstract

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. Can we write constructor in an interface?
A. yes B. no
C. cannot be determined D. not applicable

Answer and Explanation

Answer: no

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved 2012-2015 SoftLucent.