Professional Documents
Culture Documents
1.output: 1 1 2 0 3 0 1
1.output: 1 1 2 0 3 0 1
Output:
1 1 2 0 3 0 1
2.Output:
1
0
3.Output:
61
The value of y is one more than the previous member value
4.Output:
65
5.Output:
A
6.Output:
0
7.Output:
2 2
8.Output:
0
9.Output:
i)invalid
ii)valid
iii)invalid
iv)invalid
10.Output:
Hello
11.OutPut:
Error:-interface methods cannot have function definition
The interface cannot have function definition,only function declaration must be in interface.It should
be defined in the class which implements the interface
12.Output:
num1 : 150
num2 : 150
num1 : 151
num2 : 149
13.Output:
a^b = 0101
~a&b|a&~b = 0101
14.Output:
b)i iii iv v
15.Output:
true
false
16.Output:
20 20
17.Output:
2
18.Output:
i)method input() cannot have body
ii)abstract method (sum()) cannot have body
iii) class A must be abstract to override abstract method(display())
19.Output:
The format string of integer is %d so
printf(%d,si);
20.Output:
Error:
* and closed paranthesis is missing in the line,ans=10.2/a+(2*a+(3c+4)/a*d/(12/n);
Ans=10.2/a+(2*a+(3*c+4)/a*d)/(12/n);
11.040000
21.Output:
1
22.Output:
23.Output:
Run-time error since extern variable value must be assigned outside main(globally with
redeclaration)
24.Output
e
25.Output:
Friend function is not a member of any class so inorder to access member of the class,it
should use object.
friend int sum(myclass x);
int sum(myclass x)
{
return x.a +x. b;
}
26.Output:
12
27.Output:
int cl::*data; // data member pointer
int (cl::*func)(); // function member pointer
28.Output:
template <class type1 >
void add(type1 x, type1 y)
{
cout<<x<<\t<<y;
}
29.Output:
Incorrect code. ob.i is inherently ambiguous.since there will be copy of i in class derived1
and derived 2.soo when you derive it in derive3,there is an ambiguity while accessing the
variable i
30.Output:
The type of i is: int
The type of f is: float
The type of p is: char *
The type of ob1 is: class class1
The type of ob2 is: class class2<int>