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.
Briefly explain the terms used in object-oriented programming with examples.
Briefly explain the terms used in object-oriented programming with examples.
*OBJECT ORIENTED PROGRAMMING* JAVA PROGRAMMING GOAL: will be able to throw and catch exceptions and create...
*OBJECT ORIENTED PROGRAMMING* JAVA PROGRAMMING GOAL: will be able to throw and catch exceptions and create multi-threaded programs. Part I Create a class called Animal that implements the Runnable interface. In the main method create 2 instances of the Animal class, one called rabbit and one called turtle. Make them "user" threads, as opposed to daemon threads. Some detail about the Animal class. It has instance variables, name, position, speed, and restMax. It has a static boolean winner. It starts...
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.
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); }
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT