CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.




Get it now !!
Send your Resume to 6000 Companies
Operators in C++ Interview Questions & Answers - Learning Mode
COOLINTERVIEW.COM C++ INTERVIEW QUESTIONS OPERATORS IN C++ INTERVIEW QUESTIONS QUESTIONS & ANSWERS - LEARNING MODE

Operators in C++ Interview Questions & Answers - Learning Mode

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provides the following types of operators: Arithmetic Operators, Relational Operators, Logical Operators, Bitwise Operators, Assignment Operators, Misc Operators.

Try Operators in C++ Interview Questions & Answers - Exam Mode

1 2 Next

Sort By : Latest First | Oldest First | By Rating

Operators in C++ Interview Questions & Answers - Learning Mode
Try Operators in C++ Interview Questions & Answers - Exam Mode
Question: Difference between realloc() and free()?

Answer: The free subroutine frees a block of memory previously allocated by the malloc subroutine.<br>Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a<br>null value, no action will occur. The realloc subroutine changes the size of the block of memory<br>pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and<br>returns a new pointer to the block. The pointer specified by the Pointer param Source: CoolInterview.com
Question: Why can't we overload the sizeof, :?, :: ., .* operators in c++?



Answer: The restriction is for safety.For example if we overload . operator then we cant access member in normal way for that we have to use ->. Source: CoolInterview.com
Question: Why the constructor can't be virtual?

Answer: A constructor can not be virtual because at the time when the constructor is invoked the virtual table (vtable) would not be available in the memory.

Virtual allows us to call a function knowing only the interfaces and not the exact type of the object. To create an object you need complete information. In particular, you need to know the what you want to create exactly. Hence call to a constructor can't be virtual.


Source: CoolInterview.com
Question: In C++, what is a constructor,destructor?

Answer: In C++

Constructor:This is a member of class which involkes when the object is created.Purpose of constructor is to intialise the objects with required values.

Destructor: It is a member of class which involkes when the object is out of scope.The purpose of destructor is to clear the heap memory.

Submitted by divya e (mail2_divya@yahoo.com) Source: CoolInterview.com
Question: What is a scope resolution operator?

Answer: A scope resolution operator (::), can be used to define the member functions of a class outside the<br>class. Source: CoolInterview.com
Question: How to convert ascii into number value like if i typed in the letter 'R' it would give me a value of 120 0r something?

Answer: to covert it into the value follow the code below:
int i;
cout<<"enter ascii character";
cin>>i;
cout<<i; Source: CoolInterview.com
Question: What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.

Answer: An internal iterator is implemented with member functions of the class that has items to step through. .An external iterator is implemented as a separate class that can be "attach" to the object that has items to step through. .An external iterator has the advantage that many difference iterators can be active simultaneously on the same object. Source: CoolInterview.com
Question: Can you explain the term "resource acquisition is initialization?"



Answer: Resource Acquisition is Initialisation or shortly RAII is a term closely connected with exception handling and automatic garbage collection(speaking loosely). RAII is defined as the technique of performing all necessary resource initialisation work right within the body of the constructor itself, and correspondingly doing all the deallocation within the destructor. Since during exception handling destructors of all the classes whose constructors have been successfully invoked, are called therefo Source: CoolInterview.com
Question: What is aggression and association?

Answer: Association is a relationship where all object have their own life cycle and there is no owner. Let?s take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own life cycle. Both can create and delete independently.

Aggregation is a specialize form of Association where all object have their own life cycle but there is ownership and Source: CoolInterview.com
Question: Define copy constructor? What is the use of copy constructor?



Answer: A copy constructor is used to initialize a newly declared variable from an existing variableA variable is declared which is initialized from another object,A value parameter is initialized from its corresponding argument.f(p); // copy constructor initializes formal value parameter. An object is returned by a function.C++ calls a copy constructor to make a copy of an object in each of the above cases. If there is no copy constructor defined for the class, C++ uses the default copy constructor whi Source: CoolInterview.com
Question: How can you overload a method?

Answer: Different parameter data types, different number of parameters, different order of parameters. Source: CoolInterview.com
Question: Explain the scope resolution operator.

Answer: It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope. Source: CoolInterview.com
Question: What is the difference between operator new and the new operator?



Answer: This is what happens when you create a new object: 1. the memory for the object is allocated using "operator new". 2. the costructor of the class is invoked to properly initialize this memory. As you can see, the new operator does both 1 and 2. The operator new merely allocates memory, it does not initialize it. where as the new operator also initializes it properly by calling the constructor. Source: CoolInterview.com
Question: What is a scope resolution operator?

Answer: A scope resolution operator (::), can be used to define the member functions of a class outside the class. Source: CoolInterview.com
Question: what is the difference between ==and.=operator

Answer: == operator is used for comparing euqlity of two string.where as !=is used when one string is not equal to another




Regards,
Nicku Source: CoolInterview.com
Question: What is a scope resolution operator?




Answer: The scope resolution operator untangling a mess made by using <br>the same names for different kinds of entities <br> <br>base class overridden member function using the scope resolution operator (: :): <br> <br>The Fundamentals of C++ mt x,y; mt const * p; ... You can use the <br>scope resolution operator (::) to specify the desired identifier. Source: CoolInterview.com
Question: What is the difference between a copy constructor and an overloaded assignment operator?


Answer: A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class. Source: CoolInterview.com
Question: Hi I would like to know how to convert binary to decimal in c++?

Answer: By multiplying each significant number by 10. and raising the power of 10from 0 to ...from right to left. Source: CoolInterview.com
Question: Difference between a "assignment operator" and a "copy constructor"



Answer: Copy constructor is called every time a copy of an object is made. When you pass an object by value, either into a function or as a function's return value, a temporary copy of that object is made.

Assignment operator is called whenever you assign to an object. Assignment operator must check to see if the right-hand side of the assignment operator is the object itself. It executes only the two sides are not equal
Source: CoolInterview.com
Question: What is function overloading and operator overloading?

Answer: Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar Source: CoolInterview.com

1 2 Next



India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.03125 Seconds