0% found this document useful (0 votes)
18 views

Short Note

Uploaded by

ekantyadv927
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)
18 views

Short Note

Uploaded by

ekantyadv927
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/ 17

Short notes

QUES1. Inline function: -


Inline function in C++ is an enhancement feature that improves the
execution time and speed of the program. The main advantage of
inline functions is that you can use them with C++ classes as well.
QUES2. Benefits of oop: -
• OOP is faster and easier to execute
• OOP provides a clear structure for the programs
• OOP helps to keep the C++ code DRY "Don't Repeat Yourself", and
makes the code easier to maintain, modify and debug
• OOP makes it possible to create full reusable applications with less
code and shorter development time

QUES3. New vs delete


NEW DELETE
new operator is used to allocate delete operator is used to
memory dynamically. deallocates or free the dynamic
memory.
new [] operator is used to allocate delete [] operator is used to
array of data type memory deallocates or free the dynamically
dynamically. allocated memory of the array.
new returns a pointer to the delete is freed, when memory
beginning of new block. When allocated by new is no longer
memory allocates it required
new [] returns a unique pointer to delete[] deletes the array pointed
the beginning of new block. When value, returned by a pointer
allocating an array using the new
operator, the first dimension can be
zero

QUES4. STATIC DATA MEMBER: -


Static data members are class members that are declared
using static keywords. A static member has certain special characteristics
which are as follows:
• Only one copy of that member is created for the entire class and is
shared by all the objects of that class, no matter how many objects
are created.
• It is initialized before any object of this class is created, even before
the main starts.
• It is visible only within the class, but its lifetime is the entire
program.

QUES5. COPY CONSTRUCTOR: -


Copy constructors are the member functions of a class that initialize
the data members of the class using another object of the same
class. It copies the values of the data variables of one object of a
class to the data members of another object of the same class.

QUES6. VIRTUAL BASE CLASS: -


Virtual base classes offer a way to save space and avoid
ambiguities in class hierarchies that use multiple inheritances.
When a base class is specified as a virtual base, it can act as an
indirect base more than once without duplication of its data
members.
QUES7. FRIEND FUNCTION: -
A friend function is a function that isn't a member of a class but has
access to the class's private and protected members. Friend
functions aren't considered class members; they're normal external
functions that are given special access privileges

QUES8. CLASS TEMPLATE : -


Templates in C++ is an interesting feature that is used for generic programming and
templates in c++ is defined as a blueprint or formula for creating a generic class or a
function. Simply put, you can create a single function or single class to work with different
data types using templates.
QUES9. THIS POINTER:-
In C++, this pointer is used to represent the address of an object inside a
member function.

QUES10.

QUES11.
LITERALS: -
Literals are data used for representing fixed values. They can be used
directly in the code.
Here's a list of different literals in C++ programming.

1. Integers
An integer is a numeric literal(associated with numbers) without any
fractional or exponential part. There are three types of integer literals in C
programming:

• decimal (base 10)

• octal (base 8)

• hexadecimal (base 16)

2. Floating-point Literals

A floating-point literal is a numeric literal that has either a fractional form or


an exponent form.

3. Characters

A character literal is created by enclosing a single character inside single


quotation marks.

4. Escape Sequences

Sometimes, it is necessary to use characters that cannot be typed or has


special meaning in C++ programming

5. String Literals

A string literal is a sequence of characters enclosed in double-quote marks.

QUES12.
What is implicit conversion in C++?

The implicit type conversion is the type of conversion done automatically by


the compiler without any human effort. It means an implicit conversion
automatically converts one data type into another type based on some
predefined rules of the C++ compiler. Hence, it is also known as the automatic
type conversion.
QUES13.

QUES14. Difference between function overloading and


constructor overloading in c++
Answer:
In short Function overloading is used for different function with same
name but different parameter and Constructor overloading is used for
different constructor with same name but different parameter.
Explanation:
Function overloading in C++ allows multiple functions with the same name
to exist in the same scope, but with different parameter lists. This means
that a single function name can be used to perform different tasks based on
the number or type of arguments passed to it.
Constructor overloading, on the other hand, is a feature that allows multiple
constructors to exist in a class with the same name but with different
parameter lists. This allows objects of a class to be initialized in different
ways depending on the arguments passed to the constructor.

QUES15.

QUES16. What are Access Specifiers in C++?

Access Specifiers in a class decide the accessibility of the class members, like
variables or methods in other classes. That is, it will decide whether the class
members or methods will get directly accessed by the blocks present outside the
class or not, depending on the type of Access Specifier.
There are three types of access SPECIFIERS IN C++:

1. Public Access Specifier

This keyword is used to declare the functions and variables public, and any part of the entire
program can access it. The members and member methods declared public can be accessed
by other classes and functions.

The public members of a class can be accessed from anywhere in the program using
the (.) with the object of that class.

2. Private Access Specifiers

The private keyword is used to create private variables or private functions. The private
members can only be accessed from within the class. Only the member functions or the friend
functions are allowed to access the private data of a class or the methods of a class.

3. Protected Access Specifiers

The protected keyword is used to create protected variables or protected functions. The
protected members can be accessed within and from the derived/child class.

QUES17. inheritance

The capability of a class to derive properties and characteristics from another


class is called Inheritance. Inheritance is one of the most important features
of Object-Oriented Programming.
Inheritance is a feature or a process in which, new classes are created from
the existing classes. The new class created is called “derived class” or “child
class” and the existing class is known as the “base class” or “parent class”.
The derived class now is said to be inherited from the base class.

ADVANTAGES: -
1. less code is required
2. promotes code reusability
3. Inheritance can save time and effort
4. Inheritance supports the concept of reusability
Types:-

#1) Single Inheritance


In single inheritance, a class derives from one base class only. This means
that there is only one subclass that is derived from one superclass.

#2) Multiple Inheritance


Multiple inheritance is a type of inheritance in which a class derives from more
than one class.

#3) Multilevel Inheritance


In multilevel inheritance, a class is derived from another derived class.
This inheritance can have as many levels as long as our implementation
doesn’t go wayward.

#4) Hybrid Inheritance


Hybrid inheritance is usually a combination of more than one type of
inheritance.
#5) Hierarchical Inheritance
In hierarchical inheritance, more than one class inherits from a single
base class as shown in the representation above.

QUES18.explain the following terms seekg() getline() write() in c++


Seekg() is a function in the fstream library (part of the standard library) that
allows you to seek to an arbitrary position in a file.

getline() is a standard library function in C++ that is used to read a line of text
from an input stream and store it as a string

write() function shall attempt to write nbyte bytes from the buffer pointed to by
buf to the file associated with the open file descriptor, fildes.

QUES19.what are the file access mode in c++


QUES20. explain namespace in c++?
Namespaces are used to organize code into logical groups and to
prevent name collisions that can occur especially when your code
base includes multiple libraries. All identifiers at namespace scope
are visible to one another without qualification.

QUES21. explain stream class for file operations in c++?


Stream classes in C++ facilitate input and output operations on files
and other I/O devices. These classes have specific features to
handle program input and output, making it easier to write portable
code that can be used across multiple platforms.
QUES21. explain aggregation in oop?
Aggregation is a specialized form of association between two or
more objects in which each object has its own life cycle but there
exists an ownership as well. Aggregation is a typical whole/part or
parent/child relationship but it may or may not denote physical
containment.

QUES22.difference between compile time and runtime


polymorphism?
QUES23. what are the features of object oriented
programming language?

Object-Oriented Programming (OOP) languages provide developers


with powerful tools and principles for designing efficient and
maintainable software systems. The advantages of modularity, code
reusability, encapsulation, inheritance, polymorphism, and code
maintenance make OOP languages popular across various domains.
The main features of object oriented programming are as follows:
• Classes

• Objects

• Abstraction

• Polymorphism

• Inheritance

• Encapsulation

QUES24. difference between procedural programming


language and object oriented programming language?
QUES25. Express C ++ standard libraries?
• The Standard Library − This library consists of general-
purpose,stand-alone functions that are not part of any class.
The function library is inherited from C.
• I/O,
• String and character handling,
• Mathematical,
• Time, date, and localization,
• Dynamic allocation,
• Miscellaneous,
• Wide-character functions,

QUES26. different applications of OOP?


1. Software Development:

2. Development of Graphical User Interfaces (GUIs):

3. Game Development:

4. Database Management Systems:

5. Mobile App Development:

QUES27. what are abstract classes in c++?


An abstract class is a class that is designed to be specifically used
as a base class. An abstract class contains at least one pure virtual
function. You declare a pure virtual function by using a pure
specifier ( = 0 ) in the declaration of a virtual member function in the
class declaration.
QUES28.

QUES29. explain Data Hiding and encapsulation in C plus


plus?
Data encapsulation targets how the data is accessed and how
different objects behave. Data hiding focuses on object member
accessibility within a class, and information hiding is the most
common encapsulation method. The programmer conceals the
object member's structure and its implementation methods.
QUES30. what is virtual base class in c++
Virtual base classes in C++ are used to prevent multiple instances
of a given class from appearing in an inheritance hierarchy when
using multiple inheritances. Base classes are the classes from
which other classes are derived.
QUES31.how is an exception handled in C++?
Exception handling in C++ consist of three keywords: try, throw and catch:

The try statement allows you to define a block of code to be tested for errors
while it is being executed.

The throw keyword throws an exception when a problem is detected, which


lets us create a custom error.

The catch statement allows you to define a block of code to be executed, if an


error occurs in the try block.

QUES32. what are the steps involved in using a file in C


plus plus?
(i) Determine the type of link.
(ii) Declare a stream accordingly.
(iii) Link file with the stream.
(iv) Process as required, and.
(v) De-link the file with the stream.
QUES33. what are the features of generic programming?
Generic programming is about generalizing software components
so that they can be easily reused in a wide variety of situations. In
C++, class and function templates are particularly effective
mechanisms for generic programming because they make the
generalization possible without sacrificing efficiency.
QUES34. explain various type of exceptions in C plus plus?
There are two types of exceptions: a)Synchronous, b)Asynchronous (i.e.,
exceptions which are beyond the program’s control, such as disc failure,
keyboard interrupts etc.).

QUES35. explain various types of polymorphism?


The word “polymorphism” means having many forms. In simple words, we
can define polymorphism as the ability of a message to be displayed in
more than one form. A real-life example of polymorphism is a person who
at the same time can have different characteristics. A man at the same time
is a father, a husband, and an employee. So the same person exhibits
different behavior in different situations. This is called polymorphism.
Polymorphism is considered one of the important features of Object-
Oriented Programming.

Types of Polymorphism
• Compile-time Polymorphism
• Runtime Polymorphism
1. Compile-Time Polymorphism
This type of polymorphism is achieved by function overloading or operator
overloading.
A. Function Overloading
When there are multiple functions with the same name but different
parameters, then the functions are said to be overloaded,
B. Operator Overloading
C++ has the ability to provide the operators with a special meaning for a
data type, this ability is known as operator overloading
2. Runtime Polymorphism
This type of polymorphism is achieved by Function Overriding. Late binding
and dynamic polymorphism are other names for runtime polymorphism.
A. Function Overriding
Function Overriding occurs when a derived class has a definition for one of
the member functions of the base class. That base function is said to be
overridden.
B. Virtual Function
A virtual function is a member function that is declared in the base class
using the keyword virtual and is re-defined (Overridden) in the derived class
QUES36. standard libraries used in C++?
The Standard C++ Library can be categorized as follows:

• The Language Support Library


• The Diagnostics Library
• The General Utilities Library
• The Standard String Templates
• Localization Classes and Templates
• The Containers, Iterators and Algorithms Libraries (the Standard Template
Library)
• The Standard Numerics Library
• The Standard Input/Output Library
• C++ Headers for the Standard C Library
• C++ Headers added with TR1
• TR1 Headers for the Standard C Library

QUES37. explain abstract class and meta class?


An abstract class is a class that is designed to be specifically used as a base class. An
abstract class contains at least one pure virtual function.
A meta class is a class that allows for other classes to be instantiated as objects of the meta
class.

QUES38. explain data member and Member function?


A Class is a user defined data-type which has data members and
member functions. Data members are the data variables and
member functions are the functions used to manipulate these
variables and together these data members and member functions
defines the properties and behavior of the objects in a Class.
QUES39. explain how to resolve ambiguity in multiple
inheritance?
Solution of ambiguity in multiple inheritance: The ambiguity can be
resolved by using the scope resolution operator to specify the class
in which the member function lies as given below: obj. a :: abc();
QUES40. explain the features of persistent object?

Persistent objects are stored permanently in the secondary storage


of object-oriented databases. These persistent data and objects are
shared across various applications and programs. An object-
oriented database management system (OODBMS) offers
computer-generated, unique object identifiers to access each
object.

You might also like