Objects and Classes - Finding Objects and Classes - Referring to a Member Feature

3 important questions on Objects and Classes - Finding Objects and Classes - Referring to a Member Feature

Sometimes, if there are many elements with same named attribute, it becomes difficult to ...?

Sometimes, if there are many elements with same named attribute, it becomes difficult to refer to the correct one.

This could be in speech or in writing a constraint on the value.
Report


  • If we want to refer to the year attribute on Book, we would say .....?

  • To refer to the year attribute on the Video class, we would say .....?

  • If we want to refer to the slot on a book instance, we would use the name of the object, for example, ....? or ....?

Imagine that there is a Video class that also has a year attribute.

  • If we want to refer to the year attribute on Book, we would say “Book.year.”

  • To refer to the year attribute on the Video class, we would say “Video.year.”

  • If we want to refer to the slot on a book instance, we would use the name of the object, for example, “myBook.year” or “myVideo.year.”
Report

If we wanted to refer to the operation, borrow(), that might appear on both the Book and Video class.

We would refer to the operation as ......   ? and .....?

If we wanted to invoke the borrow operation on the myBook instance or on the myVideo instance, we would, in a similar manner, use .....? and .....?

This the exact approach also used to refer to a behavioral member of a class.

If we wanted to refer to the operation, borrow(), that might appear on both the Book and Video class.

We would refer to the operation as “Book.borrow()” and “Video.borrow().”

If we wanted to invoke the borrow operation on the myBook instance or on the myVideo instance, we would, in a similar manner, use myBook.borrow() and myVideo.borrow().
Report

The question on the page originate from the summary of the following study material:

  • A unique study and practice tool
  • Never study anything twice again
  • Get the grades you hope for
  • 100% sure, 100% understanding
Remember faster, study better. Scientifically proven.
Trustpilot Logo
  • Higher grades + faster learning
  • Never study anything twice
  • 100% sure, 100% understanding
Discover Study Smart