Question

In: Computer Science

-What is object-oriented programming? -What is a class? -What is an object? -A contractor uses a...

-What is object-oriented programming?

-What is a class?

-What is an object?

-A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses? Explain.

-What is a class diagram? How is it used in object-oriented programming?

-What is an attribute in OOP? What is a data member?

-What is a method in OOP? What is a member function?

-What is the difference between private members and public members of a class definition

-What is syntax to define a C++ class called Dwelling that has two data members, typeBldg as string and numRooms as integer and two member functions, setNumRooms that accepts an integer as assigns the integer to numRooms and display that prints the value of typeBldg and numRooms.

-What is a class constructor? What is a class destructor?

Solutions

Expert Solution

What is object-oriented programming?

Answer: Object-oriented programmming is a programming concept, in which whole application is based on class and its object concept. Where class is a blueprint of any real time entity and object is implementation of same to define and declare its behaviour properties.

What is a class?

Answer: Classes are building blocks of software applications. A class encapsulates data (stored in fields) and behaviour (defined by methods). It is used to build architecture of the a particular module of program, which can be later used by objects to use.

What is Object?

Answer: An object is an instance of a class. It is used to use/assign/define properties defined in corresponding class.

Example to explain Class and Object: Car is a real time entity, let suppose it as a Class and different models of it can be considered as it's objects and It is having different properties like Engine, Tyres, Chasis etc. and it is having different functions like Moving, Stopping etc.

A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the houses? Explain.

Answer: Yes, class is a kind of blue print, where actual houses are it's objects. Class provides blueprint/architecture for the objects (houses here). Based upon blueprint propeties and functions it's objects are build. For example: Properties of house which defined in it's blueprint (class) will be Doors, Windows, Walls etc. can be used it's objects (actual houses) while their implementations.

What is a class diagram? How is it used in object-oriented programming?

Answer: Class Diagram is a logical representation of class and objects with their actual implementaions and dependencies, with the order of their execution. It is used in OOPS by compiler to execute/run any program in the logical manner defined in class diagram, hence it knows about all the dependencies before hand and excute program smoothly.

What is an attribute in OOP? What is a data member?

Answer: Attribute is nothing but propeties. Attribute can be of two types Data member and Data Functions. Data member is individual property of it' class which is not having any function.

Difference between these two can be understood by below example.

Class Car

{

int engineNo; // Data Members

int chasisNo; // Data Members

int modelNo; // Data Members

void moving() // Member Functions

{
// Some Implentation

}

void braking() // Member Functions

{
// Some Implentation

}

}

What is a method in OOP? What is a member function?

Answer: Explained in Above Question

What is the difference between private members and public members of a class definition?

Answer: Private Members: These members are not accessible outiside of class and not even by it's object. These can be only accessible by it's member functions. It is recommended to use all Data members as Private.

Public Members: These members are accessible outiside of class and also by it's object. It is recommended to use all Member functions as Public.

What is syntax to define a C++ class called Dwelling that has two data members, typeBldg as string and numRooms as integer and two member functions, setNumRooms that accepts an integer as assigns the integer to numRooms and display that prints the value of typeBldg and numRooms.

Answer:

Class Dwelling
{

char typeBldg[100];
int numRooms;

void setNumRooms (int room)
{
numRooms=room;
}

void setTypeBldg (char [100] bldg) // To set typeBldg
{
typeBldg=bldg;
}


void display()
{
cout>>"NumRooms = ">>numRooms>>" typeBldg= ">>typeBldg;
}

}

What is a class constructor? What is a class destructor?

Answer: Constructor- A constructor is a method that is called whenever a new instance of a class is created. We use constructors to put an object in an early state. As a best practice, define a constructor only when an object “needs” to be initialised or it won’t be able to do its job. Constructors do not have a return type, not even void, and they should have the exact same name as the class. Constructors can be called only once (at time of object creation only). It can be overloaded.

Destructor: A destructor is just opposite of Constructor, which is called automatically when the object goes out of scope. It is also having exact same name a class and do not have a return type, not even void but it's start with a tilt (~) sign. It is used to do perform last activity before programs terminates, like closing connection Database.


Related Solutions

Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class...
Kindly Do the program in C++ language Object Oriented Programming. Objectives  Implement a simple class with public and private members and multiple constructors.  Gain a better understanding of the building and using of classes and objects.  Practice problem solving using OOP. Overview You will implement a date and day of week calculator for the SELECTED calendar year. The calculator repeatedly reads in three numbers from the standard input that are interpreted as month, day of month, days...
object oriented programming java Create a Student class that have two data members id (assign to...
object oriented programming java Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this: 20170500 Asma Zubaida
Explain what classes and objects are in object - oriented programming. Give an example of each...
Explain what classes and objects are in object - oriented programming. Give an example of each and explain how they work together in a computer program.
Research and explain in your words what is known as Object Oriented Programming. Then, identify two...
Research and explain in your words what is known as Object Oriented Programming. Then, identify two advantages of OOP for application development. In peer replies, choose from one of the following and define the concept as part of your response. Abstraction. Encapsulation. Inheritance. Polymorphism.
1. In Object Oriented Programming The private object fields can be directly manipulated by outside entities....
1. In Object Oriented Programming The private object fields can be directly manipulated by outside entities. Group of answer choices A. True B. False 2. __________ programming is centered on the procedures or actions that take place in a program. Group of answer choices A. Class B. Object-oriented C. Menu-driven D. Procedural/ Structural 3. __________ programming encapsulates data and functions in an object. Group of answer choices A. Object-oriented B. Class C. Menu-driven D. Procedural 4. The data in an...
What are the object oriented concepts and which all object oriented concepts are used in the...
What are the object oriented concepts and which all object oriented concepts are used in the given program? Consider the following code and explain how each of the object oriented concepts are applied in the given program. (CO1) class Vehicle { string brand; public: void honk(); void honk(int); }; void Vehicle::honk() { cout << "Tuut, tuut! \n" ; } void Vehicle::honk(int x) { for(int i=0;i<x;i++) cout << "Tuut, tuut! \n" ; } int main() { Vehicle V1; V1.honk(); V1.honk(3); }
Use composition relationship. What is composition? You will find out what composition in object oriented programming....
Use composition relationship. What is composition? You will find out what composition in object oriented programming. Based on the bedroom package below please create your own classroom package. After completing entire package, you will write about your package specification in Readme.txt and also explain how you apply composition to your project. package Bedroom; public class Bedroom { private String name; private Wall wall1; private Wall wall2; private Wall wall3; private Wall wall4; private Ceiling ceiling; private Bed bed; private Lamp...
Use composition relationship. What is composition? You will find out what composition in object oriented programming....
Use composition relationship. What is composition? You will find out what composition in object oriented programming. Based on the bedroom package below please create your own classroom package. After completing entire package, you will write about your package specification in Readme.txt and also explain how you apply composition to your project. package Bedroom; public class Bedroom { private String name; private Wall wall1; private Wall wall2; private Wall wall3; private Wall wall4; private Ceiling ceiling; private Bed bed; private Lamp...
Throughout this course, you will be learning about object-oriented programming and demonstrating what you learn by...
Throughout this course, you will be learning about object-oriented programming and demonstrating what you learn by writing some programs in Java. The first step will be to install and integrated development environment (IDE) that will be where you will write and compile your programs. You will also write your first program using Java to show that you have correctly installed the IDE. The project instructions and deliverables are as follows: Download and install Java JDK and NetBeans IDE using the...
What is different between procedural and object-oriented programming? Match each of the following OOP concepts with...
What is different between procedural and object-oriented programming? Match each of the following OOP concepts with its example/description. Question 2 options: 12345678 Providing a way for an entity to behave in several ways OR providing multiple entities to be treated in a similar way 12345678 A key way of saving having to retype a lot of code for similar but different objects 12345678 The removal of non-essential information 12345678 Allowing which function to be called by an object to be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT