C and Java Programming Fundamentals

Test your knowledge of C and Java programming languages including pointers, operators, expressions, threads, and serialization

12 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which conversion is not possible?

  1. int to float
  2. float to int
  3. char to float
  4. All are possible
Question 2 True/False

Can a static variable be Serialized

  1. True
  2. False
Question 3 Multiple Choice (Single Answer)

Which of the following pairs is not supported in Java

  1. Multiple Inheritance and Overloading
  2. Operator Overloading and Overriding
  3. Multiple Inheritance and Operator Overloading
  4. Pointers and Single Inheritance
Question 4 Multiple Choice (Single Answer)

Which of the below methods in Java is not used with threads

  1. wait()
  2. run()
  3. Sleep()
  4. begin()
Question 5 Multiple Choice (Single Answer)

What will be the output of the following program : #define Swap if (a != b) { \ temp=a; \ a = b; \ b = temp; \ //Swapping Done } void main() { int a=10,b=5,temp; Swap; printf("a=%d a=%d",a,b); }

  1. Compile-Time Error
  2. a=5 b=10
  3. a=10 b=5
  4. None of the above
Question 6 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int val=50; void ptr; ptr=&val; printf("%d %d",val,(int *)ptr); }C

  1. Compile-Time Error
  2. 50 50
  3. 50 0
  4. None of the above
Question 7 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int a=5,b=6; Printf("%d %d %d",a,b,--a*++b); }

  1. Compile-Time Error
  2. 5 6 30
  3. 4 7 28
  4. None of the above
Question 8 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int val=5; void *ptr; *(int )ptr=5; val=ptr; printf("%d %d",(int )val,(int *)ptr); }

  1. Compile-Time Error
  2. Unpredictable
  3. 5 5
  4. None of the above
Question 9 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int val=2; val = - --val- val--- --val; printf("%d",val); }

  1. Compile-Time Error
  2. 3
  3. -1
  4. 0
Question 10 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { int i, n =10; for (i=1; i<n--; i+=2) printf("%d\n", n-i); }

  1. 84
  2. 840
  3. 852
  4. 864
Question 11 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { printf("%f",123.); }

  1. 123
  2. Compile-Time Error
  3. 123.00
  4. 123.000000
Question 12 Multiple Choice (Single Answer)

What will be the output of the following program : void main() { printf("%d",sizeof(integer)); }

  1. 2
  2. 4
  3. Compile-Time Error
  4. None of the above