• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question from JDiscuss

 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given the following code, which statements are true?

interface A
{
int value1 = 20;
}

class B implements A
{
int value1 = 10;
}

Options

Select 1 correct option.

1. Class B implements interface A.
2. Class B is-a A.
3. class B has-a A
4. The above code will not compile.
5. value1 is overridden.

Answer given: option 1.

According to this thread option 2 is also correct.

web page

Please comment.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please comment
I agree that #2 is also correct, in that the term "IS-A" is commonly used to describe a relationship in which the class in question "is a" subtype of another class (useful in polymorphism). Because B implements A in the above example, B IS-A subtype of A and is usable wherever an instance of A is required (or at least *should* be, in principle - pun intended).

Do you have a question about this?
 
Vishnu Prakash
Ranch Hand
Posts: 1026
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is from JDiscuss Test3.

I think the question has to modified to

select 2 correct answers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic