C++ Basic Questions Answers

Explore our comprehensive guide on C++ Basic Questions Answers, designed for beginners and experienced programmers seeking to refresh their knowledge. Join us on this learning adventure and enhance your understanding of this versatile programming language. Get ready to delve into the world of C++ Basic Questions Answers and boost your programming skills. C++ Questions Answers – Part 1 (1 to 26)

C++ Basic Questions Answers – Part 2

27. How do you represent a Special Character?

An escape sequence represents a special character. Characters prefixed with a backslash (\) denote escape sequences.


28. What is the difference between a Message and a Method?

Message – A message is a way for objects to communicate with each other. A message is sent to invoke a method.

Method – Respond to a message. It is the implementation of an operation.


29. What are Access Specifiers in the C++ class?

The access specifier determines the access rights to follow until the end of the class for the statements or functions that follow them. It is up to the access specifiers to determine how to access the members of a class. Specifiers come in three types: Private, Public, and Protected.


30. What is the public access specifier?

Variables and functions created with the public keyword are public. Using the (.) with the class object, you can access the public members of a class from anywhere in the program.


31. What is the private access specifier?

When creating a private variable or function, you use the private keyword. It is possible to access private class members only from within the class. Only the member functions or the friend functions can access the private data of a class or the methods of a class.


32. What is a protected access specifier?

Using the protected keyword, you can create protected variables or functions. It is possible to access protected members both within and from the derived/child class.


33. What is Data Abstraction?

The purpose of data abstraction is to provide essential information to the outside world while hiding the background details about it.


34. What is Data Encapsulation?

Encapsulation binds data and functions together.


35. What is Polymorphism?

The term polymorph refers to many forms. The word poly means many, and the word morph means form. Basically, polymorphism is the ability to display a message in different ways.


36. What is the Scope of a Variable?

Variable scope refers to the extent of the program code within which they remain active. There are two types of scope in C++: Local Scope and Global Scope.


37. What is the Local Scope of a Variable?

When you declare a variable inside a code block, it has a local scope. It remains active and accessible only within that block and is not accessible outside of it.


38. What is the Global Scope of a Variable?

To access a variable throughout the entire C++ program, declare it at the top of the program before all the function definitions. This is possible because of its global scope.


39. What are Data Members?

Data members are the variables or attributes that hold specific data and information for each instance of a class or struct.


40. What are Member Functions?

Member functions are functions defined within a class that operates on its data members. Instances or objects of the class can call these functions to perform specific actions or operations on the class’s data.


41. What is the precedence when there are a Global variable and a Local variable in the program with the same name?

When there is a local variable with the same name as a global variable. In such cases, the compiler gives precedence to the local variable.


42. What is the default function call method?

The default function call method in C++ is the “call by value” method.


43. What is Scope Resolution Operator?

The scope resolution operator (::) to access members of a class, such as variables, functions, or nested classes, from outside the class definition or in a different scope.


44. How can we refer to the global variable if the local and the global variable names are the same? 

To refer to a global variable when there is a local variable with the same name, you can use the scope resolution operator (::) followed by the variable name. This allows you to explicitly specify the global scope and access the global variable.


45. What does Data Hiding mean?

Data hiding in object-oriented programming is the practice of encapsulating data members and member functions within a class while restricting their access from outside.


46. What is Late Binding?

Late binding in C++ selects the function implementation at runtime based on the object’s type.


47. What is the Inline Function?

When calling the inline function, it expands in line by inserting or substituting the entire code of the function at the inline function call. This helps in reducing the overhead of function calls and can result in improved performance.


48. What is the difference between Reference and Pointer?

A reference is an alias for an object, while a pointer is a variable that stores the memory address of an object and can be NULL or reassigned.


49. What do you mean by reference variable in C++?

In C++, you can declare a reference variable using the “&” operator. This reference variable acts as a different name for an existing variable, making it easy to access and modify the same memory location.


50. What is an Array of Objects?

An array of objects in C++ is a sequential collection of multiple objects of the same class type.


More Topics