Duration: 30 mins Rules: Each question carries 1 mark and 1/4 marks will be deducted for each wrong answer. 1.What does the following program print? #include<stdio.h> main() { printf(%d,main); } a)0 b)non-zero value c)compile time error d)run time error
2.What does the following program print? #include<stdio.h> #include<conio.h> #define PRINTX printf(%d\t,x); void main() { int x=2,y,z; x*=3+2;PRINTX;
8. Find the output of the following code. main() { int a=2,b=3; printf(%oa<<b); }
9.Find the output of the following code. #include<stdio.h> #include<conio.h> void main()
{ int i,j; j=0; for(i=1;i<10;i++) { continue; j=j+1; } }
10.Find the value of the following expressions: int x[10]; float y[5]; a)sizeof(x) b)sizeof(y); c)sizeof(y[1]) d)sizeof(x[2])
What is the output of the following codes,if any error identify it and correct it 11.public class s1 { static { System.out.println("guru"); } static void print() {
12. public class d1 { int num1=2; int num2=3; int num3; public static void main(String args[]) { d1 obj=new d1(); obj.num3=obj.num1<<obj.num2; System.out.println("num1<<num2 : "+obj.num3); obj.num3=obj.num1>>>obj.num2; System.out.println("num1<<<num2 : "+obj.num3); } }
13. What does the following code print? class byteshift { public static void main(String args[])
{ byte a=64,b; int i; i=a<<2; b=(byte)(a<<2); System.out.println(i and b : +i+ +b); } }
14. What does the following program print?if error identify the error. class simple { public static void main(String args[]) { if(1) System.out.println("Hi"); else System.out.println("Hello");
} }
15. What does the following program print?if error mention the error. class continue { public static void main(String args[]) {
16.What is the output of the following program? class pass1 { String[] a={"Welcome to cod guru"}; public static void main(String[] args) { for(int i=0;i<args.length;i++) System.out.println(args[+i+] : +args[i]); } } The runtime input for the above program is given below java pass1 a
17. What does the following program print?if error mention the error. final class A
{ void display() { System.out.println(Hello world); } class B extends A { public static void main(String args[]) { A obj=new A(); obj.display(); } }
18.#include<stdio.h> #include<conio.h> void main() { clrscr(); printf(%d,clrscr); } a)0 b)non-zero value c)compile time error d)run time error
19.Find the output of the following code. #include<stdio.h> #include<conio.h> void main()
{ int a=400,b=600,c; if(!(a<300)) b=500; c=800; printf(b=%d c=%d\n,b,c); }
20. Write the output of the following code main() { int a=8,b=2; int c=(a+~b)+1; printf(%d,c); } a)10 b)6 c)11 d)7
21.Write the output of the following code. void main() { const int n=5; for(int i=0;i<n;i++) { for(int j=0;j<2*n;j++) if(j<n-i||j>n+i) cout<< ; else
cout<<*; cout<<\n; } }
22. Write the output of the following code void main() { int n=66; char s[]=good bye; int* pn=&n; char* ps=s; cout<<pn = <<pn<<\n; cout<<ps= <<ps<<\n; int m=*pn; char t=*ps; cout<<m= <<m<<\n; cout<<t= <<t<<\n; }
23.Write the output of the following code. void main() { int* n; cout<<*n = <<*n<<\n; }
24.Identify the error in the following code and explain it. void main() { extern int a; clrscr(); cout<<a<<"\n"; void add() { int a=200; cout<<a; } } int a=9;
25. Identify the error in the following code and explain it. void main() { extern int a; a=7; cout<<\n<<a; getch(); }
26.What is the output of the following code. int i=0; void fun()
27.Write an equivalent code for the following code in concern with compiler. inline int max(int a, int b) { return a>b ? a : b; } void main() { cout << max(10, 20); }
28.Allocate 10 integer array of size 10 to the pointer p and release pointer using new and delete operator. int *p;
29.Which is the invalid statement in given statement i)friend class operator+(); // now a friend ii)friend class operator-(); iii)friend class operator=(); iv)friend class operator++();
30.Specify the keyword which is invalid in c++? a)asm b)mutable c)reinterpret_cast d)external