0% found this document useful (0 votes)
16 views2 pages

Object Oriented Questions

Uploaded by

haniyah710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Object Oriented Questions

Uploaded by

haniyah710
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Explain the benefits of object-oriented programming(OOP)

There are many benefits of object-oriented programming, including the fact that it is
concise, organized, and allows for the different objects to work together to create a
program. Classes can be classified as a data type, which allows for an extra organization
feature. OOP is also beneficial because it groups the code into smaller seperate files to be
worked on separately. Classes can be used and called in different lines of code, making it
easier to start a new project. This is because you can use old classes that you have
created.

2. Discuss the different between a class and an object

A class could be considered as a blueprint made by the student or programmer


themselves. It defines a type of code, in a separate file that defines the data type of the
data structure, whereas an object consists of different classes.

3. Discuss the difference between properties and methods of a class?

The characteristics of a class are the properties. These properties/characteristics of the


class are things that are represented as variables.

The behaviours of the what the class does and is for are the methods. These methods are
represented as functions.

4. What is a code reuse? How does it relate to inheritance?

Reusing code means to create a class, then extend that class to create a subclass. That
subclass can then be called to the code and reused. This means the programmer does not
have to keep rewriting code that they’ve already written. Going back to subclasses, when
you create a subclass, that subclass inherits all of the class's methods and properties. It
also is able to define other properties or methods.

Reusing code relates to inheritance because the subclasses that allow the programmer to
reuse code, inherits properties and methods of the main class.

5. What is Polymorphism? How does it relate to methods?


Polymorphism is the idea that an object is able to take on many different forms. THis
means that a class can override methods from superclasses.

6. Explain how the concepts of encapsulation and delegation:

a) Relate to each other

Encapsulation and delegation both work together to create an efficient program. Both
concepts main idea to create an efficient program.

They also differ from the fact that delegation uses other responsibilities to achieve specfic
tasks. The class delegates the responsibility of the program, if it is given a task that is
outside of the written responsibility of the code. Encapsulation means that the code has
one area of responsibility.

b) how they differ from each other

Encapsulation does one thing, the responsibility it was written for, but delegation is the
opposite. It delegates the responsibilities of the program to other pieces of code.

You might also like