click below
click below
Normal Size Small Size show me how
CP2-Module 8
Introduction to OOP: Basic Concepts, Member Functions, and Inheritance.
Question | Answer |
---|---|
A behavior of an object is called: Method Abstract class Property | Method |
It is an identifiable entity with some characteristics and behavior Properties Methods Class Object | Object |
Which of the following has a correct C++ class definition? class Student {}: class Student {}; class Student; class Student () | class Student {}; |
Objects created are based on what? abstract behavior class attributes | class |
What operator is used to access a data member or a member function? dot (.) operator + operator & operator == operator | dot (.) operator |
It means displaying only essential information and hiding the details. Methods Class Abstraction Object | Abstraction |
Refers to binding together the data and the functions that manipulate them Objects Encapsulation Class Abstraction | Encapsulation |
Which is not a feature of OOP in general definitions? Duplicate/Redundant Data Code reusability Efficient code Modularity | Duplicate/Redundant Data |
Pick out the other definition of objects. attribute of the class associate of the class member of the class instance of the class | instance of the class |
What symbol is used to define a function outside of the class? :: & <> : | :: |
If an object named Apple has a member named "price", what is the command to assign a value of 15 into it? Apple.price == 15; Apple(15); Apple.price = 15; Price(15); | Apple.price = 15; |
Which of the following statements is correct in C++? Structures can have functions as members Classes cannot have data as protected members. Class members are public by default. Structure members are private by default | Structures can have functions as members |
Which of the following concepts means wrapping up of data and functions together? Inheritance Encapsulation Abstraction Object | Encapsulation |
The default access specifier for the class members is: none of the given protected public private | private |
Which of the following is an abstract data type? double int class string | class |
Which of the following term is used for a function defined inside a class? Member function Classic function Class function Member Variable | Member function |
A Function that has its definition or its prototype within the class definition like any other variable. Member Functions Objects Data Member Class | Member Functions |
If an object named Box has a member of length, what is the command to assign a value of 5 into it? Box.length = 5; Box.length == 5; Length = 5; Box(5) | Box.length = 5; |
Which concept of OOP is false for C++? Code can be written without using classes Code must contain at least one class At least one object should be declared in code A class must have member functions | Code must contain at least one class |
What is the difference between struct and class in C++? | Members of a class are private by default and members of struct are public by default. |
Blueprint of an object Inheritance Object Class Data Members | Class |
If there is a class named Student and you want to create an object name "firstyear", what would be the correct syntax student firstyear student firstyear() student first year; Student firstyear | Student firstyear |
Which of the following best defines a class? Instance of an object Blueprint of an object Scope of an object Parent of an object | Blueprint of an object |
How many classes can be defined in a single program? Only 999 Only 100 Only 1 As many as you want | As many as you want |
What is the output of the given program? #include<iostream> using namespace std; main() { class student { int rno = 10; } v; cout<<v.rno; } Group of answer choices Error 0 10 Garbage value | Error, variables inside a class cannot be initialized at declaration like that. "rno" is also a private member/instance variable. |
What is the output of this program? class Test { int x; }; int main() { Test t; cout << t.x; return 0; } Group of answer choices -1 0 Garbage value Error | Error, "x" is a private member/instance variable. |
What is the difference between a struct and a class in C++? A struct cannot have member functions A struct cannot have private members A class has a default privacy specification of private A class has a default privacy specification of public | A class has a default privacy specification of private |
If a class is named Car and you will create an object named SportsCar, what would be the statement? Car<SportsCar>; SportsCar Car; Car SportsCar; Car (SportsCar); | Car SportsCar; |
It refers to the blueprint of an object: Inheritance Access Modifier Class Data | Class |
If a class is named Fruits and you will create an object named Apple, what would be the statement? Fruits Apple; Apple Fruits; Apple@Fruits; Fruits(Apple); | Fruits Apple; |
Which of the following are available only in the class hierarchy chain? Protected data members Member functions Public data members Private data members | Protected data members |