A Learning Portal from Recruitment India
Static variable in a class is initialized when _____ .
every object of the class is created.
last object of the class is created.
first object of the class is created.
No need to initialize static variable.
Answer with explanation
Answer: Option CExplanation
first object of the class is created.
Workspace
#include<iostream> using namespace std; void main() { char s[] = "C++"; cout<<s<<" "; s++; cout<<s<<" "; }
– C++ C++
– C++ ++
++ ++
– Compile error
Answer with explanation
Answer: Option DExplanation
‘s’ refers to a constant address and cannot be incremented.
#include<iostream> using namespace std; void main() { char s[] = "C++"; cout<<s<<" "; s++; cout<<s<<" "; }
Workspace
Which of the following functions will correctly return true if its argument is an odd integer?
I. bool IsOdd (int x) {
return (x % 2 == 1);
}
II. bool IsOdd (int x) {
return (x / 2 == 1);
}
III. bool IsOdd (int x) {
if (x % 2 == 1)
return true;
else
return false;
}
II only
I and II only
I and III only
II and III only
Answer with explanation
Answer: Option CExplanation
I and III only
Workspace
Which one of the following is correct about the statements are given below?
All function calls are resolved at compile-time in Procedure Oriented Programming.
All function calls are resolved at compile-time in OOPS.
Only II is correct.
Both I and II are correct.
Only I is correct.
Both I and II are incorrect.
Answer with explanation
Answer: Option CExplanation
Only I is correct.
Workspace
In the case of binary operator overloading with member function, which of the following statement should be taken into consideration?
The left-hand operand must object.
The right-hand operand must be object.
Both the operands must be objects.
All of these should be considered.
Answer with explanation
Answer: Option AExplanation
The left-hand operand must be object.
Workspace
Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object
Inheritance
Polymorphism
Abstraction
Encapsulation
Answer with explanation
Answer: Option BExplanation
Abstraction
Workspace
Only functions of the class can access the data of the class and they(functions) provide the interface between data, objects and the program. This kind isolation of the data from direct access by the program is called _______________ .
Data Abstraction
Data Hiding
Data Binding
Data Encapsulation
Answer with explanation
Answer: Option BExplanation
Data Hiding
Workspace