473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Simple doubt... Please help

dmjpro
2,476 2GB
look at this example.....

Expand|Select|Wrap|Line Numbers
  1. class InterfaceTest1
  2. {
  3.   void test();
  4. }
  5. class ClassTest1
  6. {
  7.    public void test(){}
  8. }
  9. class ClassTest2 extends ClassTest1 implements Interface
  10. {
  11.    public void test(){} //Method overriden or method implementation?
  12. }
  13.  
How it is posiible ......???

Please explain.

Kind regards,
Dmjpro.
Jun 19 '07 #1
5 1381
r035198x
13,262 8TB
look at this example.....

Expand|Select|Wrap|Line Numbers
  1. class InterfaceTest1
  2. {
  3.   void test();
  4. }
  5. class ClassTest1
  6. {
  7.    public void test(){}
  8. }
  9. class ClassTest2 extends ClassTest1 implements Interface
  10. {
  11.    public void test(){} //Method overriden or method implementation?
  12. }
  13.  
How it is posiible ......???

Please explain.

Kind regards,
Dmjpro.
You got your class names and variable names wrong there dj. The method test is overriden of course and also the class satisfies the contract of the interface by implementing the method test as well. Normally this is not done because it's useless. Either you're using an abstract class or an interface. And choice is usually obvious.
Jun 19 '07 #2
dmjpro
2,476 2GB
You got your class names and variable names wrong there dj. The method test is overriden of course and also the class satisfies the contract of the interface by implementing the method test as well. Normally this is not done because it's useless. Either you're using an abstract class or an interface. And choice is usually obvious.

Actually what happens to me.
Today I see the Collection interface carefully.
There I see a method int hashCode() and the class which by default extends Object and implements Collection interface or it's sub-interfaces have to implement the method int hashCode().
That's why I questioned it.

Kind regards,
Dmjpro.
Jun 19 '07 #3
r035198x
13,262 8TB
Actually what happens to me.
Today I see the Collection interface carefully.
There I see a method int hashCode() and the class which by default extends Object and implements Collection interface or it's sub-interfaces have to implement the method int hashCode().
That's why I questioned it.

Kind regards,
Dmjpro.
It is important for concrete classes to implement it that's why it was included in that interface.
Jun 19 '07 #4
dmjpro
2,476 2GB
It is important for concrete classes to implement it that's why it was included in that interface.
Yup right.
But Object class itself contains int hashCode() method.

Kind regards,
Dmjpro.
Jun 19 '07 #5
JosAH
11,448 Expert 8TB
Actually what happens to me.
Today I see the Collection interface carefully.
There I see a method int hashCode() and the class which by default extends Object and implements Collection interface or it's sub-interfaces have to implement the method int hashCode().
That's why I questioned it.

Kind regards,
Dmjpro.
You don't *have to* implement hashCode() and its compadre equals(), those
methods are just part of the interface to emphasize that you should reimplement
them in several occasions. Read the Collection API docs for those two methods.
And of course, if you don't implement them the interface contract is still fulfilled
because the Object class implements them both (but not the way some collections
expect them to be implemented).

kind regards,

Jos
Jun 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

31
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? ...
138
by: ambika | last post by:
Hello, Am not very good with pointers in C,but I have a small doubt about the way these pointers work.. We all know that in an array say x,x is gonna point to the first element in that...
6
by: Baskar RajaSekharan | last post by:
In C-sharp, I wnat to know whether the Component is compiled in Debug Mode or Run Mode through Code. How is it possible? Is there any way to Access the Config file and check? Please let me know...
3
by: Baskar RajaSekharan | last post by:
Hi, Please clarify my doubt in C#. I have one Dll which is created in (VC7). I want to load the Dll dynamically in my C# project. How to do that. How to load the Dll Dynamically. In Vb,...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
4
by: Christian O'Connell | last post by:
Hi, please excuse this, my third posting today. It is my last I promise. When I past this into form1, I am expecting to see "Start0Start01Start012Start0123". But what I see is "Start0 Start01...
7
by: bfowlkes | last post by:
Hi, I am new to the C programming language and programming in general. I am writing a simple roulette program. I have everything working so far but it seems a little plain. What I would like to...
26
by: jacob navia | last post by:
Summary: I have changed (as proposed by Chuck) the code to use isalpha() instead of (c>='a' && c <= 'z') etc. I agree that EBCDIC exists :-) I eliminated the goto statement, obviously it is...
122
by: ivan | last post by:
hi all, if I have: if(A && B || C) which operation gets executed first? If I remeber well should be &&, am I correct? thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.