Questions & Answers On OOPs Concept & Features
Questions & Answers On OOPs Concept & Features
Questions & Answers On OOPs Concept & Features
sanfoundry.com
Answer: c
Explanation: SmallTalk was the first programming language
developed which was purely object oriented. It was
developed by Alan Kay. OOP concept came into picture in
1970’s.
1 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
d) Scope of an object
View Answer
Answer: b
Explanation: A class is Blueprint of an object which
describes/ shows all the functions and data that are
provided by an object of a specific class. It can’t be called
as parent or instance of an object. Class in general
describes all the properties of an object.
Answer: a
Explanation: Alan Kay invented OOP, Andrea Ferro was a
part of SmallTalk Development. Dennis invented C++ and
Adele Goldberg was in team to develop SmallTalk but Alan
actually had got rewarded for OOP.
Answer: b
Explanation: Member functions are allowed inside a class
2 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: Duplicate/Redundant data is dependent on
programmer and hence can’t be guaranteed by OOP. Code
reusability is done using inheritance. Modularity is
supported by using different code files and classes. Codes
are more efficient because of features of OOP.
Answer: b
Explanation: It’s false because for a program to be pure
OO, everything must be written inside classes. If this rule is
violated, the program can’t be labelled as purely OO.
3 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
d) Inheritance
View Answer
Answer: d
Explanation: Using inheritance we can reuse the code
already written and also can avoid creation of many new
functions or variables, as that can be done one time and be
reused, using classes.
Answer: b
Explanation: Java doesn’t support all 4 types of inheritance.
It doesn’t support multiple inheritance. But the multiple
inheritance can be implemented using interfaces in Java.
Answer: d
Explanation: Any number of classes can be defined inside a
program, provided that their names are different. In java, if
public class is present then it must have the same name as
4 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
that of file.
Answer: a
Explanation: OOP first came into picture in 1970’s by Alan
and his team. Later it was used by some programming
languages and got implemented successfully, SmallTalk
was first language to use pure OOP and followed all rules
strictly.
Answer: a
Explanation: As Java supports usual declaration of data
variables, it is partial implementation of OOP. Because
according to rules of OOP, object constructors must be
used, even for declaration of variables.
5 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: In C++, it’s not necessary to use classes, and
hence codes can be written without using OOP concept.
Classes may or may not contain member functions, so it’s
not a necessary condition in C++. And, an object can only
be declared in a code if its class is defined/included via
header file.
Answer: d
Explanation: We need not include any specific header file to
use OOP concept in C++, only specific functions used in
code need their respective header files to be included or
classes should be defined if needed.
Answer: c
Explanation: Encapsulation and Abstraction are similar
6 of 7 3/19/18, 9:26 AM
Object Oriented Programming Online Test about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Use of this pointer allows an object to call data
and methods of itself whenever needed. This helps us call
the members of an object recursively, and differentiate the
variables of different scopes.
7 of 7 3/19/18, 9:26 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: c
Explanation: Only 9 types of classes are provided in
general, namely, abstract, final, mutable, wrapper,
anonymous, input-output, string, system, network. We may
further divide the classes into parent class and sub class if
inheritance is used.
1 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
b) Reference
c) Value or Reference, depending on program
d) Copy
View Answer
Answer: b
Explanation: Classes are pass by reference, and the
structures are pass by copy. It doesn’t depend on program.
Answer: a
Explanation: The data members and member functions are
Private by default in C++ classes, if none of the access
specifier is used. It is actually made to increase the privacy
of data.
class Student
{
int a;
public : float a;
};
2 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Same variable can’t be defined twice in same
scope. Even if the data types are different, variable name
must be different. There is no rule like Public member
should come first or last.
Answer: c
Explanation: Template classes are known to be generic
classes because those can be used for any data type value
and the same class can be used for all the variables of
different data types.
6. Size of a class is :
a) Sum of size of all the variables declared inside the class
b) Sum of size of all the variables along with inherited
variables in the class
c) Size of largest size of variable
d) Classes doesn’t have any size
View Answer
3 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
Answer: d
Explanation: Classes doesn’t have any size, actually the
size of object of the class can be defined. That is done only
when an object is created and its constructor is called.
Answer: d
Explanation: Abstract classes can have member functions
with no implementation, where the inheriting sub classes
must implement those functions.
Answer: a
Explanation: A friend class can access all the private
members of another class, of which it is friend. It is a
special class provided to use when you need to reuse the
4 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
Answer: d
Explanation: It depends on the access specifier and the
type of inheritance used with the class, because if the class
is inherited then the nested class can be used by subclass
too, provided it’s not of private type.
Answer: a
Explanation: The class containing main function can be
inherited and hence the program can be executed using the
derived class names also in java.
5 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: Member functions must be declared inside
class body, thought the definition can be given outside the
class body. There is no way to declare the member
functions inside the class.
Answer: b
Explanation: Keyword class should come first. Class name
should come after keyword class. Parameterized
constructor definition depends on programmer so it can be
left empty also.
Answer: b
Explanation: Class and structure are similar to each other.
Only major difference is that a structure doesn’t have
6 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: Class definition must end with a semicolon, not
colon. Class can have only member functions in its body
with no data members.
Answer: d
Explanation: Instance of abstract class can’t be created as
it will not have any constructor of its own, hence while
creating an instance of class, it can’t initialize the object
members. Actually the class inheriting the abstract class
can have its instance, because it will have implementation
of all members.
7 of 8 3/19/18, 9:27 AM
Classes - Object Oriented Programming Questio... about:reader?url=https://www.sanfoundry.com/...
8 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: a
Explanation: An object is instance of its class. It can be
declared in the same way that a variable is declared, only
thing is you have to use class name as the data type.
1 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
View Answer
Answer: d
Explanation: You can create as many objects of a specific
class as you want, provided enough memory is available.
Answer: c
Explanation: Objects can be passed by reference. Objects
can be passed by value also. If object of a class is not
created, we can’t use members of that class.
Answer: c
Explanation: The array must be specified with a size. You
can’t declare object array, or any other linear array without
specifying its size. It’s a mandatory field.
2 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
b) Passed by value
c) Passed by copy
d) Passed as function
View Answer
Answer: d
Explanation: Object can’t be passed as function as it is an
instance of some class, it’s not a function. Object can be
passed by reference, value or copy. There is no term
defined as pass as function for objects.
Answer: c
Explanation: The size of any object of student class will be
of size 4+20=24, because static members are not really
considered as property of a single object. So static
variables size will not be added.
Answer: b
3 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Using dot operator after the name of object we
can access its members. It is not necessary to use the
pointers. We can’t use the names directly because it may
be used outside the class.
Answer: d
Explanation: For an object which belongs to a local class, it
is mandatory to declare and use the object within the
function because the class is accessible locally within the
class only.
4 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: We can never create instance of an abstract
class. Abstract classes doesn’t have constructors and
hence when an instance is created there is no facility to
initialize its members. Option d is correct because topper
class is inheriting the base abstract class student, and
hence topper class object can be created easily.
Answer: c
Explanation: The object declared in main() have local scope
inside main() function only. It can’t be used outside main()
function. Scope resolution operator is used to access
globally declared variables/objects.
5 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: A temporary object is created to return the
value. It is created because object used in function is
destroyed as soon as the function is returned. The
temporary variable returns the value and then gets
destroyed.
Answer: c
Explanation: Only if the objects are of same class then their
data can be copied from to another using assignment
operator. This actually comes under operator overloading.
Class constructors can’t be assigned any explicit value as in
option b and d.
class student{
int marks;
6 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
int cgpa;
public: student(int i, int j){
marks=I;
cgpa=j
}
};
Answer: b
Explanation: It is the way we can initialize the data
members for an object array using parameterized
constructor. We can do this to pass our own intended
values to initialize the object array data.
Answer: b
Explanation: The explanation given is wrong because object
can always be used with pointers like with any other
variables. Compiler doesn’t have to know the structure of
the class to use a pointer because the pointers only points
to a memory address/stores that address.
7 of 8 3/19/18, 9:27 AM
Objects Questions and Answers - Sanfoundry about:reader?url=https://www.sanfoundry.com/...
8 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: b
Explanation: Inheritance indicates the code reusability.
Encapsulation and abstraction are meant to hide/group data
into one element. Polymorphism is to indicate different
tasks performed by a single entity.
1 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
a) Encapsulation
b) Inheritance
c) Polymorphism
d) Abstraction
View Answer
Answer: c
Explanation: For the feature given above, the OOP feature
used is Polymorphism. Example of polymorphism in real life
is a kid, who can be a student, a son, a brother depending
on where he is.
Answer: d
Explanation: It is Encapsulation, which groups different
properties and functions of a real world entity into single
element. Abstraction, on other hand, is hiding of functional
or exact working of codes and showing only the things
which are required by the user.
2 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
d) Functions Overloading
View Answer
Answer: c
Explanation: Data must be declared using objects. Object
usage is mandatory because it in turn calls its constructors,
which in turn must have a class defined. If object is not
used, it is violation of pure OOP concept.
Answer: a
Explanation: Platform independence is not feature of OOP.
C++ supports OOP but it’s not a platform independent
language. Platform independence depends on
programming language.
a) Inheritance
b) Polymorphism
c) Inheritance and polymorphism
d) Encapsulation and Inheritance
3 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
View Answer
Answer: d
Explanation: Encapsulation is indicated by use of classes.
Inheritance is shown by inheriting the student class into
topper class. Polymorphism is not shown here because we
have defined the constructor in topper class but that doesn’t
mean that default constructor is overloaded.
Answer: d
Explanation: All the features are violated because
Inheritance and Encapsulation won’t be implemented.
Polymorphism and Abstraction is still possible in some
cases, but the main features like data binding, object use
and etc won’t be used hence use of class is must for OOP
concept.
4 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: There are 7 basic features that define whether
a programing language is pure OOP or not. The 4 basic
features are inheritance, polymorphism, encapsulation and
abstraction. Further, one is, object use is must, secondly,
message passing and lastly, Dynamic binding.
Answer: c
Explanation: The interaction between two object is called
message passing feature. Data transfer is not feature of
OOP. Also, message reading is not feature of OOP.
Answer: d
Explanation: Virtual Functions can be defined in any class
using the keyword virtual. All the classes which inherit the
class containing the virtual function, define the virtual
5 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: The feature is operator overloading. There is
not feature named operator overriding specifically. Function
overloading and overriding doesn’t give addition function to
any operator.
Answer: b
Explanation: Function overriding doesn’t illustrate
polymorphism because the functions are actually different
and theirs scopes are different. Function and operator
overloading illustrate proper polymorphism. Virtual functions
show polymorphism because all the classes which inherit
virtual function, define the same function in different ways.
6 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Exception handling is feature of OOP as it
includes classes concept in most of the cases. Also it may
come handy while using inheritance.
Answer: d
Explanation: The language must follow all the rules of OOP
to be called a purely OOP language. Even if a single OOP
feature is not followed, then it’s known to be a partially OOP
language.
Answer: a
7 of 8 3/19/18, 9:27 AM
OOP Features - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
8 of 8 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: a
Explanation: It is actually the ability for a message / data to
be processed in more than one form. The word
1 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: The languages which support classes but
doesn’t support polymorphism, are known as object-based
languages. Polymorphism is such an important feature, that
is a language doesn’t support this feature, it can’t be called
as a OOP language.
Answer: d
Explanation: Ada is the language which supports the
concept of classes but doesn’t support the polymorphism
feature. It is an object-based programming language. Note
that it’s not an OOP language.
2 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: The feature defined in question defines
polymorphism feature. Here the different objects are
capable of responding to the same message in different
ways, hence polymorphism.
3 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
{
public : calc_grade()
{
return 20;
}
};
class failed{ int marks; };
Answer: c
Explanation: Since Student class is abstract class and class
topper and average are inheriting student, class topper and
average must define the function named calc_grade(); in
abstract class. Since both the definition are different in
those classes, calc_grade() will work in different way for
same input from different objects. Hence it shows
polymorphism.
4 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: Only virtual functions among these can show
polymorphism. Class member functions can show
polymorphism too but we should be sure that the same
function is being overloaded or is a function of abstract
class or something like this, since we are not sure about all
these, we can’t say whether it can show polymorphism or
not.
Answer: b
Explanation: Function with highest priority is called. Here,
it’s not about the thread scheduling in CPU, but it focuses
on whether the function in local scope is present or not, or if
scope resolution is used in some way, or if the function
matches the argument signature. So all these things define
which function has the highest priority to be called in
runtime. Local function could be one of the answer but we
can’t say if someone have used pointer to another function
or same function name.
5 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Static member functions are not property of
any object. Hence it can’t be considered for
overloading/overriding. For polymorphism, function must be
property of object, not only of class.
class student
{
public : int marks;
void disp()
{
cout<<”its base class”
};
class topper:public student
{
public :
void disp()
{
cout<<”Its derived
class”;
}
6 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
}
void main() { student s; topper t;
s.disp();
t.disp();
}
Answer: a
Explanation: You need to focus on how the output is going
to be shown, no space will be given after first message from
base class. And then the message from derived class will
be printed. Function disp() in base class overrides the
function of base class being derived.
Answer: c
Explanation: Only insertion operator can be overloaded
among all the given options. And the polymorphism can be
illustrated here only if any of these is applicable of being
overloaded. Overloading is type of polymorphism.
7 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
class education
{
char name[10];
public : disp()
{
cout<<”Its education
system”;
}
class school:public education
{
public: void dsip()
{
cout<<”Its school
education system”;
}
};
void main()
{
school s;
s.disp();
}
}
Answer: a
8 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: It is possible to implement polymorphism in C
language, even though it doesn’t support class. We can use
structures and then declare pointers which in turn points to
some function. In this way we simulate the functions like
member functions but not exactly member function. Now we
can overload these functions, hence implementing
polymorphism in C language.
Answer: c
Explanation: The undefined functions must be defined is a
problem, because one may need to implement few
undefined functions from abstract class, but he will have to
9 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: d
Explanation: It never increases function definition overhead,
one way or other if you don’t use polymorphism, you will
use the definition in some other way, so it actually helps to
write efficient codes.
Answer: d
Explanation: Both of them are using polymorphism. It is not
a necessary that polymorphism can be used only once in a
10 of 11 3/19/18, 9:27 AM
Polymorphism - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
11 of 11 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: d
1 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: We can define public member functions to
access those private data members and get their value for
use or alteration. They can’t be accessed directly but is
possible to be access using member functions. This is done
to ensure that the private data doesn’t get modified
accidently.
2 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: Data member’s data type can be changed
without changing any further code. All the members using
that data can continue in the same way without any
modification. Member functions can never change the data
type of same class data members.
Answer: b
Explanation: Data abstraction can be achieved by using
encapsulation. We can hide the operation and structure of
actual program from the user and can show only required
information by the user.
3 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
View Answer
Answer: c
Explanation: It is the class which uses both the data
members and member functions being declared inside a
single unit. Only data members can be there in structures
also. And the encapsulation can only be illustrated if some
data/operations are associated within class.
Answer: d
Explanation: Immutable classes are used for caching
purpose generally. And it can be created by making the
class as final and making all its members private.
Answer: a
Explanation: The data prone to change in near future is
usually encapsulated so that it doesn’t get changed
accidently. We encapsulate the data to hide the critical
4 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Using access specifiers we can achieve
encapsulation. Using this we can in turn implement data
abstraction. It’s not necessary that we only use private
access.
Answer: b
Explanation: Global variables almost always violates the
principles of encapsulation. Encapsulation says the data
should be accessed only by required set of elements. But
global variable is accessible everywhere, also it is most
prone to changes. It doesn’t hide the internal working of
program.
5 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
programming?
a) Using access declaration for private members of base
class
b) Using access declaration for public members of base
class
c) Using access declaration for local variable of main()
function
d) Using access declaration for global variables
View Answer
Answer: a
Explanation: If using access declaration for private
members of base class was allowed in programming, it
would have destroyed whole concept of encapsulation. As if
it was possible, any class which gets inherited privately,
would have been able to inherit the private members of
base class, and hence could access each and every
member of base class.
Answer: d
Explanation: If we use any kind of array or pointer as data
6 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
class student
{
int marks;
public : int* fun()
{
return &marks;
}
};
main()
{
student s;
int *ptr=c.fun();
return 0;
}
Answer: d
Explanation: This code violates the encapsulation. By this
code we can get the address of the private member of the
7 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
class hero
{
char name[10];
public : void disp()
{
cout<<name;
}
};
Answer: a
Explanation: This code maintains encapsulation. Here the
private member is kept private. Outside code can’t access
the private members of class. Only objects of this class will
be able to access the public member function at maximum.
Answer: b
8 of 9 3/19/18, 9:27 AM
Encapsulation - Object Oriented Programming ... about:reader?url=https://www.sanfoundry.com/...
Answer: b
Explanation: The encapsulation can only ensure the data
security to some extent. If pointer and addresses are
misused, it may violate encapsulation. Use of global
variables also makes the program vulnerable, hence we
can’t say that encapsulation gives pure security.
9 of 9 3/19/18, 9:27 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
sanfoundry.com
Answer: d
Explanation: It includes hiding the implementation part and
showing only the required data and features to the user. It
is done to hide the implementation complexity and details
from the user. And to provide a good interface in
programming.
1 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: It can make the programming easy. The
programming need not know how the inbuilt functions are
working but can use those complex functions directly in the
program. It doesn’t provide more number of features or
better features.
Answer: b
Explanation: Class is logical abstraction because it provides
a logical structure for all of its objects. It gives an overview
of the features of an object.
Answer: c
Explanation: Object is real abstraction because it actually
2 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: It is to idealize the interface. In this way the
programmer can use the programming features more
efficiently and can code better. It can’t increase the program
complexity, as the feature itself is made to hide it.
Answer: a
Explanation: Abstraction applies to both. Control abstraction
involves use of subroutines and control flow abstraction.
Data abstraction involves handling pieces of data in
meaningful ways.
3 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
b) Object
c) Inheritance
d) Interfaces
View Answer
Answer: b
Explanation: Object can be viewed as abstraction of data
and code. It uses data members and their functioning as
data abstraction. Code abstraction as use of object of inbuilt
class.
Answer: c
Explanation: Abstraction principle includes use of
abstraction to avoid duplication (usually of code). It this way
the program doesn’t contain any redundant functions and
make the program efficient.
Answer: b
Explanation: Higher the level of abstraction, lower are the
details. The best way to understand this is to consider a
whole system that is highest level of abstraction as it hides
4 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
Answer: a
Explanation: Abstraction is hiding the complex code. For
example we directly use cout object in C++ but we don’t
know how is it actually implemented. Encapsulation is data
binding, as in, we try to combine the similar type of data
and functions together.
Answer: a
Explanation: Abstraction is called stream to provide a level
of complexity hiding, for how the files operations are
actually done. Actual devices are called file because in one
way or other, those can be considered as single entity and
there is nothing hidden.
5 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
Answer: c
Explanation: It is the concept of hiding program complexity
and actual working in background. Hence use of public
member functions illustrates abstraction here.
Answer: d
Explanation: Phone as a whole have the highest level of
abstraction. This is because the phone being a single unit
represents the whole system. Whereas motherboard,
display and camera are its components.
6 of 7 3/19/18, 9:28 AM
Abstraction - Object Oriented Programming Que... about:reader?url=https://www.sanfoundry.com/...
Answer: d
Explanation: Abstraction is generally divided into 3 different
levels, namely, logical, physical and view level. External
level is not defined in terms of abstraction.
Answer: c
Explanation: It will make the code safer. One may think it
reduces the readability, but the fact is, it actually helps us
understand the code better. We don’t have to read the
complex code which is of no use in understanding the
program.
7 of 7 3/19/18, 9:28 AM