C++ Interview Questions
- 0of 0 votes
AnswersGiven a mathematical expression, remove the redundant brackets from the expression.
- maverick April 11, 2013 in United States
e.g. input: (a + (b*c)) * (d * ( f * j) )
output should be: (a + b * c) *d * f * J
operations to support: +, -, /, *, ++, also ternary operators.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
Answerswhich of the following is true for static member of the class?
- sohit April 09, 2013 in India
a) internal linkage
b) external linkage| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 1of 1 vote
Answers#include<iostream>
- sohit April 09, 2013 in India
#include<exception>
int main()
{
try
{
cout << "sum";
throw 3;
}
catch(...)
{
cout<< "dot";
}
catch(int a)
{
cout << a;
}
catch(exception e)
{
cout << "exception";
}
return 0;
}
what will be the output of the above program?| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 0of 2 votes
AnswerFor the written test please prepare the following topics throughly :
- sohit April 09, 2013 in India
a) virtual function
b) operator overloading
c) namespace
d) template
For interview, please prepare the container throughly with the implementation of list,map etc.| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 0of 2 votes
Answersclass a{
- sohit April 09, 2013 in United States
public:
int var1;
a(int var)
{
var1 = var;
}
};
class b: public a
{
public:
int var2;
b(int d) : var2( d++) , a(var2++)
{
}
};
int main
{
b obj1(5);
}
What will be the value of the variable 'var1' in class A?
a) 6
b)7
c) 5
d) undefined| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 0of 0 votes
Answersclass a{ public: int a; virtual void sum() { printf("sum"); } }; class b : public a { public: int b; virtual void sum() { printf("sum of class b"); } }; void main() { b aptr; a *bptr; bptr = &aptr; bptr->sum(); }
Output of the above program?
- sohit April 09, 2013 in United States| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 0of 0 votes
AnswersWhy the size of the empty class is one?
- sohit April 09, 2013 in India
What are the default functions in an empty class.
does the size of empty class depend upon the compiler or hardware(32 bit or 64 bit)?| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer C++ - 0of 0 votes
Answers1. What is difference between override and overload
- JSDUDE April 08, 2013 in United States
2. abstract. when will u use abstract
3. what is an interface
4. what is difference betwwen array and link list
5. what is a tree
6. what is a map\dictionary
7. Explain (orally) how would you implement a dictionary via a tree| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 1of 1 vote
AnswersIf an N X N matrix is given, print it in spiral order.
- GKR April 07, 2013 in United States
Example: Below is 5 X 5 matrix
i l o v e
d i n t e
n i e e p
a v w r i
m a x e c
Print in spiral order. Output is iloveepicexamandinterview| Report Duplicate | Flag | PURGE
Epic Systems Algorithm C C++ C# Coding Java - -3of 3 votes
AnswersDesign and code static simulator for all gates .i.e. AND / OR / XOR etc.
- hprem991 March 29, 2013 in United States
Where the simulator has to work properly not only for the binary digit but also for the algebraic inputs (i.e doubles as a input type.)| Report Duplicate | Flag | PURGE
Senior Software Development Engineer Algorithm C++ - 0of 0 votes
AnswersHow do we design a class.forName("CLASS") , kind of function?
- hprem991 March 27, 2013 in United States
Where the function will accept a string (as a Class Name) as a parameter and accordingly convert it into the subsequent CLASS object.| Report Duplicate | Flag | PURGE
Solutions Architect Algorithm C++ - 0of 0 votes
AnswersThere are some exceptions that cannot be caught by try catch. How to catch such exceptions? Can we prevent our program to crash if we are not able to catch such exceptions.
- DashDash March 26, 2013 in India| Report Duplicate | Flag | PURGE
Samsung Software Engineer / Developer C++ - 0of 0 votes
AnswersDesign LRU in C++
- hprem991 March 18, 2013 in India| Report Duplicate | Flag | PURGE
StartUp Software Architect Algorithm C++ - 0of 0 votes
AnswerDesign Garbage Collector in C++.
- hprem991 March 18, 2013 in India| Report Duplicate | Flag | PURGE
StartUp Software Architect Algorithm C++ - 0of 0 votes
AnswersDesign a Tic Tac Toe Game. Classes Segregation and Code Flow.
- hprem991 March 18, 2013 in India| Report Duplicate | Flag | PURGE
StartUp Amazon Software Architect Software Engineer / Developer Algorithm Android Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C++ Object Oriented Design - 3of 3 votes
AnswersWrite a program to sort an array of strings so that all anagrams are next to each other
- Neo March 07, 2013 in United States for Web Service
ex
input {god, dog, abc, cab, man}
output {abc, cab, dog, god, man}| Report Duplicate | Flag | PURGE
Amazon Intern C++ Java - 0of 0 votes
AnswersI have a virtual function in base class BASE and in derived class DERIVED, I have overridden the virtual function. I will create 10 object of DERIVED class.Ex: DERIVED d1,d2...d10. How many v tables are created in this scenario?
- Bharath February 07, 2013 in United States| Report Duplicate | Flag | PURGE
C++ - 0of 0 votes
AnswersHow is mutual exclusion done in C++?
- andrew February 05, 2013 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - 0of 0 votes
AnswersHow would you implement Garbage Collection in C++?
- andrew February 05, 2013 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C++ - -1of 1 vote
AnswersWrite some functions in c/c++ and then re-write the same function that can improve performance(cpu/memory etc) and explain why?
- dindin February 02, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft C++ - 2of 2 votes
Answersimplement your own sizeof() operator..
- ishanimahajan7 January 29, 2013 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C++ - 0of 0 votes
AnswersThe producers write elements to a ring buffer(fixed size) while the consumers access elements from it. Implement a write and a read function using a producer pointer and consumer pointer. The consumer pointer cannot surpass the producer pointer and when the producer pointer reaches where it starts again, it stops.
- crazyomg23 January 17, 2013 in United States| Report Duplicate | Flag | PURGE
Apple Software Engineer / Developer C++ - 1of 1 vote
AnswersGiven a String "abcxrrxabcrr"
- vigneshselvakumar January 10, 2013 in United States
Find the first repeated string with minimum 3 character?
Answer is "abc" min 3 characters.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C++ - 0of 0 votes
AnswersGiven an input string , "this is apple ****" replace all occurences of "apple" with another word say "freedom" .The interviewer insisted on returning the modified string as an array. No input parameter for writing the output provided.Dont know how can an array be returned in c or cpp . Returning the pointer to a local array would definitely not work .
- kk December 29, 2012 in India
Please comment.| Report Duplicate | Flag | PURGE
Software Engineer / Developer C++ - 0of 2 votes
AnswersA log file which has user details(user ID,timestamp) and pages visited in a particular day by that user.The next day -the same kind of log file gets generated.How do you find the probability of users who logged in consecutive days out of the second day - logged in users? The question is simple,but they look for the efficient data structure and time complexity.
- sriramMS December 20, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C# C++ Cache Coding Data Mining Data Structures - 0of 0 votes
AnswersI am given a third-party library with its header to use. Now this library has a class 'Base'. Problem with this class is that it does not have virtual destructor. Now since i don't have the thirds-party code with me i can not do changes over there.
- Xyz December 15, 2012 in India
I am told to write few derived classes with this and make sure that the object gets cleaned properly when objects are delete. How can we achieve this?| Report Duplicate | Flag | PURGE
C++ - -1of 1 vote
AnswersWhy here output is not Derived Class????
- patilsanketv December 15, 2012 in India
#include <iostream>
using namespace std;
class Base {
public:
char* name;
void display() {
cout << name << endl;
}
};
class Derived: public Base {
public:
char* name;
void display() {
cout << name << ", " << Base::name << endl;
}
};
int main() {
Derived d;
d.name = "Derived Class";
d.Base::name = "Base Class";
Derived* dptr = &d;
// standard conversion from Derived* to Base*
Base* bptr = dptr;
// call Base::display()
bptr->display();
}
// OUTPUT
Base Class| Report Duplicate | Flag | PURGE
Google Developer Program Engineer C++ - 0of 0 votes
Answers#include <iostream> #include <stdio.h> using namespace std; class A{ public: void fun(int& temp){cout<<"am inside fun()"<<endl; temp = 2000; printf("in fun() temp[%p] temp val[%d]\n",&temp, temp); } }; const int temp=100; int main() { A a; printf("in main() temp[%p] temp val[%d]\n",&temp, temp); a.fun(const_cast<int&>(temp)); cout<<"temp:"<<temp<<endl; }
Questions:
- pradeep December 11, 2012 in India
1> when i run this pgm @ line "temp=2000;" pgm will crash. what is the reason for sigsegv in this case?
2> if i make const int temp=100; declaration inside main() then, no crash and value change (i.e. temp=2000;) persists only inside fun(). But in the scope of main() this changed value is not seen. whats happening here? But address of temp in both the cases shows the same!! how is this possible??| Report Duplicate | Flag | PURGE
Wipro Technologies Software Analyst C++ - 0of 0 votes
AnswersGiven a string like 01011011001, convert it to 00000111111 with best efficiency possible.
- AK November 30, 2012 in India| Report Duplicate | Flag | PURGE
C++ - 0of 0 votes
AnswersHow can we have an Abstract Class without any using any virtual Function in it ?
- d.sujith November 27, 2012 in India| Report Duplicate | Flag | PURGE
Aricent Technical Architect C++