Home C C++ Java Python Perl PHP SQL JavaScript Linux Selenium QT Online Test

Home » List of Companies » KPIT Questions

KPIT C & C++ Objective Type Interview Questions

Location: Pune, India
Experience Required: 3 - 6 years
Job Profile:C & C++ with Linux

Question 1: Software entities (classes, modules, functions, etc) should be open to modification, but closed for extension?
A: True
B: False

Question 2: What is the index of the last element in an array of 19 elements?
A: 0
B: 19
C: 18
D: 20
E: Undefined

Question 3: In a base 2 system (binary), what is the value of 01 | 11 ?
A: 11
B: 10
C: 100
D: 01
E: 00

Question 4: Type of the result displayed by this piece of code ?
int i = 0;
cout << i++;
A: 0
B: 1
C: 2
D: Undefined

Question 5: What is the value returned by sizeof(char) ?
A: 1
B: It depends on the compiler
C: It depneds on the system architecture
D: 8
E: 4
F: 32
G: It depends on the system endcoding

Question 6: An inline function ?
A: Decreases execution speed
B: Increases or decreases execution speed
E: Increases execution speed

Question 7: What is the value returned by sizeof(int) ?
A: 64
B: It depends on the compiler/or computer architecture
C: 4
D: 32
E: 8
F: 2
G: 1

Question 8: In the following code what is the value of val?
class A
{
public:
virtual int get() { return 1; }
};

Class B
{
public:
virtual int get() { return 2; }
};

class C: public A, public B
{
};

int main()
{
C *obj = new C();
int val = obj->get();
return 0;
}

Question 9: What is the value of val in following code?
class A
{
public:
int value() { return 1; }
};

class B: public A
{
public:
int value() { return 2; }
};

int main()
{
A *obj = newB();
int val = obj->value();
return 0;
}
A: Undefined
B: 1
C: The code does not compile
D: 2

Question 10: What is printed by this code?
int a()
{
cout<<"a";
return 0;
}

int b()
{
cout<<"b";
return 0;
}

int main()
{
if(a() || b())
{
cout<<"main";
}
}

A: Nothing is printed
B: main
C: Compilation error
D: Undefined

Question 11: From the below code, select the true statements
void func1()
{
MyObject o;
}

void func2()
{
MyObject o();
}

A: In func2, the default constructor of MyObject will be called
B: In func1, o is an instance of MyObject
C: In func1, the default constructor of MyObject will be called
D: In func2 o is an instance of the MyObject

Question 12: What is printed by this code?
typedef struct{
unsigned int i: 1;
}myStruct;

int main()
{
myStruct s;
s.i = 1;
s.i++;
cout< return 0;
}

A: -1
B: 1
C: 3
D: 0
E: segmentation fault
F: 2

Question 13: What is printed by this code?
class A
{
public:
static void print(int a) { cout<<"int"; }
static void print(float a) { cout<<"float"; }
static void print(double a) { cout<<"double"; }
static void print(bool a) { cout<<"bool"; }
};

int main()
{
int a = 1;
A::print(a * 0.1);
return 0;
}