Easy Tutorial
For Competitive Exams

Oracle Technical TestWhat will be the output of the following program on GCC compiler?

#include

int main() {

char str[]=`MalayalaM`;

char $\times$ s;

s= str + 8;

while(s>=str){

printf("%c", $\times$ s);

s--;

}

return 0;

}

M
MalayalaM
MM
Garbage Value
Explanation:

The address of the 8th character from the base address of the string` is stored in the character pointer `s`.Here, `s` is pointing to the 8th value in the `str` i.e. `M`.

In the start of the loop, since the address at `s` is greater than the address at `str`, the condition evaluates to true. Then printf() prints the value at address at s` i.e. `M` and the value of `s` is decremented which will now point to the 7th value in the `str` i.e. `a`.

In the same way loop is executed and the characters `str` are printed in reverse order. When the address at `s` becomes less than the address at `str`, the loop is terminated. Hence, we get the output "MalayalaM".

Additional Questions

Which of the statements is correct about the following program on GCC compiler?

int main() {

char a[]="Add";

int * j;

j = &a;

printf("%c\n", * j+2);

return 0;

}

Answer

Which is true about a method-local inner class?

Answer

What will be the output of the program?

public class Switch2 {

final static short x = 2;

public static int y = 0;

public static void main(String [] args) {

for (int z=0; z < 4; z++) {

switch (z) {

case x:

System.out.print("0 ");

default:

System.out.print("def ");

case x-1:

System.out.print("1 ");

break;

case x-2:

System.out.print("2 ");

}}}}

Answer

What will be the output of the program?

class Base {

Base() {

System.out.print("Base");

}

}

public class Alpha extends Base {

public static void main(String[] args) {

new Alpha(); / * Line 12 * /

new Base(); / *Line 13 * /

}

}

Answer

Which collection class allows you to associate its elements with key values, and allows you to retrieve objects in FIFO (first-in, first-out) sequence?

Answer

What will be the output of the program?

for(int i = 0; i < 3; i++) {

switch(i) {

case 0: break;

case 1: System.out.print("one ");

case 2: System.out.print("two ");

case 3: System.out.print("three ");

}

}

System.out.println("done");

Answer

What will be the output of the following program on GCC?

int main(){

static int c=5;

printf("c=%d",c--);

if(c)

main();

return 0;

}

Answer

What is the base class for all Exception ?

Answer

In SQL, which command is used to remove a stored function from the database?

Answer

bus is a / an

Answer
Share with Friends
Privacy Copyright Contact Us