Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Could someone verify that my thinking is correct..


  • Please log in to reply

#1
BigBadTex

BigBadTex

    New Member

  • Member
  • Pip
  • 3 posts
I have a couple problems here that I have answered. I am not 100% sure of my answer(s). Would you be so kind as to check them and provide suggestions if they are not correct. These 2 questions are regarding what methods super/sub class(es) can invoke (question1) and which objects invoke which methods (question2). Thanks in advance.

Question 1
==================================================
Super Class: Expression (Includes prefix, postfix, and infix expressions)
Public Method: characterAt
Protected Method: isOperator
Protected Method: isIdentifier
Private Method: somePrivateMethoda
Private Method: somePrivateMethodb

SubClass: InfixExpression (Derived from Expression. Represents infix expression)
Public Method: isLegal
Public Method: evaluate
Protected Method: someProtectedMethoda
Protected Method: someProtectedMethodb
Private Method: anotherPrivateMethoda
Private method: anotherPrivateMethodb
==================================================
What methods can the implementation of isIdentifier invoke?
CharacterAt
isOperator
somePrivateMethoda
somePrivateMethodb

What methods can the implementation of isLegal invoke?
characterAt
isOperator
isIdentifier
evaluate
someProtectedMethoda
someProtectedMethodb
anotherPrivateMethoda
anotherPrivateMethodb


Question 2
Assuming the classes described in the previous question and consider a main method that contains:

Expression algExp;
InfixExpression infixExp;

Soooo...
==================================================
Super Class: Expression (Includes prefix, postfix, and infix expressions)
Main Method: algExp
Public Method: characterAt
Protected Method: isOperator
Protected Method: isIdentifier
Private Method: somePrivateMethoda
Private Method: somePrivateMethodb

SubClass: InfixExpression (Derived from Expression. Represents infix expression)
Main Method: infixExp
Public Method: isLegal
Public Method: evaluate
Protected Method: someProtectedMethoda
Protected Method: someProtectedMethodb
Private Method: anotherPrivateMethoda
Private method: anotherPrivateMethodb
==================================================
Which of these objects can correctly invoke the method CharacterAt?
algExp and infixExp

Which of these objects can correctly invoke the method isOperator?
algExp and infixExp

Which of these objects can correctly invoke the method isLegal?
infixExp
  • 0

Advertisements







Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP