4 Replies - 510 Views - Last Post: 09 October 2011 - 02:41 PM Rate Topic: -----

#1 sameerRKO  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-September 11

abstract classes

Posted 09 October 2011 - 02:30 PM

hello everyone, i am a java student and got stuck on a question. can someone help me UNDERSTANDING and SOLVING the question. your help will be greatly appreciated.help me understand the question,i do not want codes. NO STUPID ANSWER please

Question 1
Applying the object-oriented concepts of encapsulation and inheritance, implement a
super class called MyCounter with an integer instance variable called value. The class
has a default constructor and a user-defined constructor. Its public interface has one
permissible operation called accessValue() which allows return of its instance variable.
Implement 2 subclasses of MyCounter called CountUp and CountDn. The CountUp
class with its derived constructors defines an increment counter that provides the
increment privilege called increment(). The CountDn class defines a decrement counter
that provides the decrement privilege called decrement().
Implement a class called TestMyCounter which will simulate the 2 instances of subclass
as follow:
(i). To increment an object of CountUp (with initialize value 11) by 100 times and
display the final value of its instance variable.
(ii). To decrement an object of CountDn (with initialize value 22) by 19 times and display
the final value of its instance variable.

Is This A Good Question/Topic? 0
  • +

Replies To: abstract classes

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2198
  • View blog
  • Posts: 5,226
  • Joined: 10-September 10

Re: abstract classes

Posted 09 October 2011 - 02:32 PM

What don't you understand?
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,111
  • Joined: 27-December 08

Re: abstract classes

Posted 09 October 2011 - 02:36 PM

We have two tutorials on abstract classes and interfaces you may find helpful:
http://www.dreaminco...1&#entry1378692
http://www.dreaminco...implementation/
Was This Post Helpful? 0
  • +
  • -

#4 sameerRKO  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-September 11

Re: abstract classes

Posted 09 October 2011 - 02:38 PM

Quote

The class
has a default constructor and a user-defined constructor


what will the names,they cannot have the same name
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10567
  • View blog
  • Posts: 39,111
  • Joined: 27-December 08

Re: abstract classes

Posted 09 October 2011 - 02:41 PM

Actually, they do have the same name. Additional constructors work the same as overloading methods- they just have different parameter lists.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1