GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark ""is a" and "has a"" Watch ""is a" and "has a"" New topic
Author

"is a" and "has a"

Judy YU
Ranch Hand

Joined: Nov 19, 2000
Posts: 30
As I understand, if class A extends class B, we can say that class A is a B, and if in the definition of class A, there is object C (such as Interface , class objects) as class or instance member, we can say A has C. Then, how about class A implements interface E, do we say A is a E? I saw in some mock exam, it is declared as A is-like-a E, but it is not an official term in Java. Can anyone help?
Question 2: is the declaration " all integer types are signed numbers " true or false? As I know, it is true because all integer types(short, byte, int, long) are signed numbers. If "integral type" is used here instead of "integer type", then it will be wrong since integral type includes char as well. Agree?

Val Dra
Ranch Hand

Joined: Jan 26, 2001
Posts: 439
Question 2: is the declaration " all integer types are signed numbers " true or false? As I know, it is true because all integer types(short, byte, int, long) are signed numbers. If "integral type" is used here instead of "integer type", then it will be wrong since integral type includes char as well. Agree?
No not all integer values are signed , char is unsigned only positive values 0 - 65000 i believe. Although it's still a numeric type.


Val SCJP <BR>going for SCJD
Gaurav Mantro
Ranch Hand

Joined: Sep 08, 2000
Posts: 61
As for Question 1.
My understanding is that implements also represents "is a" relationship. "Implements" is implementation of Inheritance only. The diference in implements and extends is that in implement we do not inherit the implementation but just the method signatures and in extends we inherit the implementation also. So from OO prospective they both should be Java's implementation of OO principle of Inheritance and hence the relationship "is a".


----------------------<br />regards.<br /><a href="http://www.mantrotech.com/editors/gaurav_mantro.asp" target="_blank" rel="nofollow">Gaurav Mantro</a><br /><a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">Java Information Portal</a> - <a href="http://www.mantrotech.com/technology/java/index.asp" target="_blank" rel="nofollow">http://java.mantrotech.com</a>
Judy YU
Ranch Hand

Joined: Nov 19, 2000
Posts: 30
Thanks for your kind reply.
As for question 2: in KR book , page 29, Khalid Mughal provides a chart which separated integer type from character type, although integral type includes both char and integer type. Did Mughal write it wrong? I am really confused.
Judy
Sujit Kurtadikar
Ranch Hand

Joined: Dec 05, 2000
Posts: 68
class A extends B implemnts C
{
Emp e;
}
This can be interpreted as,
class A "is a" class B
class A "behaves like" class C
class A "has a" class Emp
I don't know whether "behaves like" term is used by Java or not,
but it is correct interpretation.
Also we can say, Class A "is like a" Class C
Sridhar Katakam
Greenhorn

Joined: Jan 28, 2001
Posts: 8

Four Signed integral types: byte, short, int, long
Unsigned integral type: char
Primitive type 'boolean' is unsigned but it doesn't come under 'integral' types.
I am 100 % sure about the above.
Now coming to integer types, I believe what Judy quoted is true that integer types cover byte, short, int and long which are signed. But ValDra wrote indicating that 'char' is a integer type. How is that possible ?
~Sri~

Originally posted by Val Dra:
Question 2: is the declaration " all integer types are signed numbers " true or false? As I know, it is true because all integer types(short, byte, int, long) are signed numbers. If "integral type" is used here instead of "integer type", then it will be wrong since integral type includes char as well. Agree?
No not all integer values are signed , char is unsigned only positive values 0 - 65000 i believe. Although it's still a numeric type.

 
GeeCON Prague 2014
 
subject: "is a" and "has a"