2
Q:

public abstract interface Frobnicate { public void twiddle(String s); } 

Which is a correct class?

A) public abstract class Frob implements Frobnicate { public abstract void twiddle(String s) { } } B) public abstract class Frob implements Frobnicate { }
C) public class Frob extends Frobnicate { public void twiddle(Integer i) { } } D) public class Frob implements Frobnicate { public void twiddle(Integer i) { } }

Answer:   B) public abstract class Frob implements Frobnicate { }



Explanation:

B is correct, an abstract class need not implement any or all of an interface’s methods

Subject: Programming
Q:

What is the output of this C code?

   #include <stdio.h>
    int main()
    {
        int a = 1, b = 1;
        switch (a)
        {
        case a*b:
            printf("yes ");
        case a-b:
            printf("non");
            break;
        }
    }

A) yes B) no
C) Compile time error D) yes no
 
Answer & Explanation Answer: C) Compile time error

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

7 18729
Q:

What is the output of this C code?

        #include <stdio.h>
        void main()
        {
            int x = 97;
            char y = x;
            printf("%cn", y);
        }

A) a B) 97
C) Run time error D) None
 
Answer & Explanation Answer: A) a

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

1 11932
Q:

What is the output of this C code?

        #include <stdio.h>
        void main()
        {
            int y = 3;
            int x = 5 % 2 * 3 / 2;
            printf("Value of x is %d", x);
        }

A) Value of x is 1 B) Value of x is 2
C) Value of x is 3 D) Compile time error
 
Answer & Explanation Answer: A) Value of x is 1

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 10473
Q:

What is the output of this C code?

       #include <stdio.h>
        void main()
        {
            int x = 1, z = 3;
            int y = x << 3;
            printf( "%dn", y );
        }

A) -2147483648 B) -1
C) Run time error D) 8
 
Answer & Explanation Answer: D) 8

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: Programming

2 14681
Q:

Output of the Program :

main()

{

int i = 1;

while (i <= 5)

    {

         printf( "%d", i );

         if (i > 2) goto here;

         i++;

     }

}

fun()

{

here : printf( "PP" );

}

A) 1 B) 2
C) Compilation error D) Exception occurs
 
Answer & Explanation Answer: C) Compilation error

Explanation:

Compiler error: Undefined label 'here' in function main

Report Error

View Answer Report Error Discuss

Filed Under: Programming

3 13299
Q:

main()

{

char *p; p = "Hello";

printf ("%cn", *&*p);

}

A) H B) Hello
C) Compilation error D) H E L L O
 
Answer & Explanation Answer: A) H

Explanation:

* is a dereference operator & is a reference operator. They can be applied any number of times provided it is meaningful. Here p points to the first character in the string "Hello". *p dereferences it and so its value is H. Again & references it to an address and * dereferences it to the value H

Report Error

View Answer Report Error Discuss

Filed Under: Programming
Job Role: Software Architect

19 30524
Q:

void main()

{

char good *better, *best;

printf( "%d..%d", sizeof(better), sizeof(best) );

}

A) 1..2 B) 4..4
C) 4..2 D) 2..2
 
Answer & Explanation Answer: C) 4..2

Explanation:

The second pointer is of char type and not a good pointer.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

4 11960
Q:

enum colors {BLACK,BLUE,GREEN}

main()

{

printf( "%d..%d..%d", BLACK, BLUE, GREEN );

return(1);

}

A) 1..2..3 B) 0..1..2
C) 1..1..1 D) 0..0..0
 
Answer & Explanation Answer: B) 0..1..2

Explanation:

enum assigns numbers starting from 0, if not explicitly defined.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

8 19138