100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Assignment 2_ Theory solutions £6.51   Add to cart

Exam (elaborations)

Assignment 2_ Theory solutions

 0 view  0 purchase

Assignment 2_ Theory solutions

Preview 1 out of 2  pages

  • June 22, 2024
  • 2
  • 2023/2024
  • Exam (elaborations)
  • Questions & answers
All documents for this subject (127)
avatar-seller
modockochieng06
Assignment 2: Theory solutions
What is the purpose of the keywords public and private in the class declaration? - correct
answer-The public keyword is used to declare a member variable or function that may be
directly accessed from outside the class.
The private keyword is used to declare a member variable or function that cannot be directly
accessed from outside the class. These members can only be accessed/modified with the
use of an accessor/mutator function.

What is the difference between a class and an object? - correct answer-A class is a user
defined type that defines a collection of properties and methods which can be accessed by
creating an instance of that class.
An object is an instance of a class. It is usually a real-world entity.

What does it mean to 'instantiate' an object? - correct answer-Instantiating an object is when
we create an instance of an object. The object is given a name and created in memory.

What is the purpose of a constructor? - correct answer-A constructor is used to initialize an
object when it is created.

What is the difference between the default constructor and the overloaded constructor? -
correct answer-Both have the same name that matches the class name,
A default constructor is one that takes no parameters and is automatically generated if the
user doesn't define one. It is used to assign default values to the member variables.
An overloaded constructor takes one or more parameters that assign custom values to the
member variables.

What is the purpose of a destructor? - correct answer-A destructor is used to free up
resources used by an object, it deallocates the memory and performs other cleanup actions.

What is the purpose of an accessor? - correct answer-An accessor is used to access/read
private class data from outside the class.

What is the purpose of a mutator? - correct answer-A mutator is used to modify/set/change
private class data from outside the class.

What is the purpose of the scope resolution operator? - correct answer-A scope resolution
operator can be used to:
• Access a global variable when there is a local variable with the same name
• Define a class function from outside the class
• Access a class's static variables

What is the difference between the scope resolution operator and the dot operator? - correct
answer-A scope resolution operator is used with a class name. It is two consecutive colons.
It indicates the class name to which an object belongs

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller modockochieng06. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for £6.51. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

75323 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy revision notes and other study material for 14 years now

Start selling
£6.51
  • (0)
  Add to cart