Clash of Codes

Is this your test? Login to manage it. If not, you can generate an assessment just like it.

This is a non-interactive preview of the quiz content.

1.
What is the output of this program?
#include
using namespace std;
int main()
{
int a[2][4] = {3, 6, 9, 12, 15, 18, 21, 24};
cout << *(a[1] + 2) << *(*(a + 1) + 2) << 2[1[a]];
return 0;
}
2.
What is the output of this program?

#include
using namespace std;
int main()
{
int arr[] = {4, 5, 6, 7};
int *p = (arr + 1);
cout << *p;
return 0;
}
3.
What will be the output of the program?
#include
#include

union employee
{
char name[15];
int age;
float salary;
};
const union employee e1;

int main()
{
strcpy(e1.name, "K");
printf("%s %d %f", e1.name, e1.age, e1.salary);
return 0;
}
4.
What is the output?
void main() {
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
5.
What will be the output of the following snippet?

try
{
int x = 0;
int y = 5 / x;
}
catch (Exception e)
{
System.out.println("Exception");
}
catch (ArithmeticException ae)
{
System.out.println(" Arithmetic Exception");
}
System.out.println("finished");
6.
What will be the output of the following snippet?

public class Foo
{
public static void main(String[] args)
{
try
{
return;
}
finally
{
System.out.println( "Finally" );
}
}
}
7.
What will be the output of following program?

class ThreadEx extends Thread
{
public void run()
{
Thread.sleep(100);
System.out.println("Hello");
}
public static void main(String args[])
{
ThreadEx T1=new ThreadEx();
T1.start();
}
}
8.
What will be output if you will compile and execute the following c code?
void main(){
int i=320;
char *ptr=(char *)&i;
printf("%d",*ptr);
}
9.
What will be the output?

class PassA
{
public static void main(String [] args)
{
PassA p = new PassA();
p.start();
}

void start()
{
long [] a1 = {3,4,5};
long [] a2 = fix(a1);
System.out.print(a1[0] + a1[1] + a1[2] + " ");
System.out.println(a2[0] + a2[1] + a2[2]);
}

long [] fix(long [] a3)
{
a3[1] = 7;
return a3;
}
}
10.
What happens when we try to compile the class definition in following code snippet?

class Birds {};
class Peacock : protected Birds {};
11.
What will be the output of the following snippet?

public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod()
{
throw new Error(); /* Line 22 */
}
}
12.
What will be the output of the program?

#include

int main()
{
char far *near *ptr1;
char far *far *ptr2;
char far *huge *ptr3;
printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
return 0;
}
13.
Which one is a valid declaration of a boolean?
14.
State True or False

Offset used in fseek() function call can be a negative number
15.
To print out a and b given below, which of the following printf() statement will you use?

#include

float a=3.14;
double b=3.14;
16.
What will be the output?

public static void main(String [] args)
{
PassS p = new PassS();
p.start();
}

void start()
{
String s1 = "slip";
String s2 = fix(s1);
System.out.println(s1 + " " + s2);
}

String fix(String s1)
{
s1 = s1 + "stream";
System.out.print(s1 + " ");
return "stream";
}
}
17.
Consider the following snippet and select the correct statement to start the thread.

public class ThreadEx extends Thread
{
public void run()
{
System.out.println("Running...");
}

public static void main(String args[])
{
ThreadEx T1=new ThreadEx();
__________ /*start thread*/
}
}
18.
Which of the following function prototype is perfectly acceptable?
19.
What will be the output of the program in 16 bit platform (Turbo C under DOS) ?

#include

int main()
{
struct value
{
int bit1:1;
int bit3:4;
int bit4:4;
}bit;
printf("%d\n", sizeof(bit));
return 0;
}
20.
How will you free the allocated memory ?
21.
size of union is size of the longest element in the union
22.
What will be the output ?

public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (RuntimeException ex) /* Line 10 */
{
System.out.print("B");
}
catch (Exception ex1)
{
System.out.print("C");
}
finally
{
System.out.print("D");
}
System.out.print("E");
}
public static void badMethod()
{
throw new RuntimeException();
}
}
23.
What will be the output of following program?

class ThreadEx extends Thread
{
public void run()
{
for(int loop=1;loop<=5;loop++)
{
System.out.print(loop);
}
}
public static void main(String args[])
{
ThreadEx T1=new ThreadEx();
ThreadEx T2=new ThreadEx();

T1.start();
T2.start();
}
}
24.
What will be the output of the program?
#include

int main()
{
int y=128;
const int x=y;
printf("%d\n", x);
return 0;
}
25.
What is meaning of following declaration?

int(*p[5])();