O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×

Consider the following interface and class- Public interface A { publ.docx

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio

Confira estes a seguir

1 de 2 Anúncio

Consider the following interface and class- Public interface A { publ.docx

Baixar para ler offline

Consider the following interface and class:
Public interface A {
public void m1( );
public void m2( );
}
Public class C implements A {
// code for class C
}
What must be true about the code for class C in order for that code to compile successfully?
A.
class C should have at least one call each for methods m1 and m2
class C should contain an abstract method m1 and abstract method m2
class C does not have to do anything as it already \"implements\" class A and has inherited both m1 and m2
class C should contain the definitions of methods m1 and m2 as concrete methods (fully written methods included in class C that contains code in the method bodies)
Solution
Answer is D. When you implements a class then you have to fully write the methods which are present in its interface. Class implementing any interface must implement all the methods, otherwise the class should be declared as “abstract”.
.

Consider the following interface and class:
Public interface A {
public void m1( );
public void m2( );
}
Public class C implements A {
// code for class C
}
What must be true about the code for class C in order for that code to compile successfully?
A.
class C should have at least one call each for methods m1 and m2
class C should contain an abstract method m1 and abstract method m2
class C does not have to do anything as it already \"implements\" class A and has inherited both m1 and m2
class C should contain the definitions of methods m1 and m2 as concrete methods (fully written methods included in class C that contains code in the method bodies)
Solution
Answer is D. When you implements a class then you have to fully write the methods which are present in its interface. Class implementing any interface must implement all the methods, otherwise the class should be declared as “abstract”.
.

Anúncio
Anúncio

Mais Conteúdo rRelacionado

Semelhante a Consider the following interface and class- Public interface A { publ.docx (20)

Mais de kaseya1 (20)

Anúncio

Mais recentes (20)

Consider the following interface and class- Public interface A { publ.docx

  1. 1. Consider the following interface and class: Public interface A { public void m1( ); public void m2( ); } Public class C implements A { // code for class C } What must be true about the code for class C in order for that code to compile successfully? A. class C should have at least one call each for methods m1 and m2 class C should contain an abstract method m1 and abstract method m2 class C does not have to do anything as it already "implements" class A and has inherited both m1 and m2 class C should contain the definitions of methods m1 and m2 as concrete methods (fully written methods included in class C that contains code in the method bodies) A. class C should have at least one call each for methods m1 and m2 B. class C should contain an abstract method m1 and abstract method m2 C. class C does not have to do anything as it already "implements" class A and has inherited both m1 and m2 D. class C should contain the definitions of methods m1 and m2 as concrete methods (fully written methods included in class C that contains code in the method bodies) Solution
  2. 2. Answer is D. When you implements a class then you have to fully write the methods which are present in its interface. Class implementing any interface must implement all the methods, otherwise the class should be declared as “abstract―.

×