This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
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?
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.
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".
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
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
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.