28
Q:

main()

{

char s[ ] = "man";

int i;

for( i=0; s[ i ]; i++)

printf( "n%c%c%c%c", s[ i ], *(s+i), *(i+s), i[s] );

}

A) mmmm aaaa nnnn B) aaaa mmmm nnnn
C) nnnn aaaa mmmm D) None

Answer:   A) mmmm aaaa nnnn



Explanation:

s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea.Generally array name is the base address for that array. Here s is the base address. i is the index number/displacement from the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is same as s[i].

Subject: Programming
Q:

#define clrscr() 100

main()

{

clrscr();

printf( "%dn", clrscr() );

}

A) 100 B) 0
C) Compilation error D) Exception occurs
 
Answer & Explanation Answer: A) 100

Explanation:

Preprocessor executes as a seperate pass before the execution of the compiler. So textual replacement of clrscr() to 100 occurs.The input program to compiler looks like this :

main ()

{

100;

printf("%d\n",100);

}

Note: 100; is an executable statement but with no action. So it doesn't give any problem.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

13 27661
Q:

A function cannot be defined inside another function

A) TRUE B) FALSE
Answer & Explanation Answer: A) TRUE

Explanation:

A function cannot be defined inside the another function, but a function can be called inside a another function.

Report Error

View Answer Workspace Report Error Discuss

Subject: Programming

5 9296
Q:

What value does read() return when it has reached the end of a file?

A) 1 B) -1
C) 0 D) None
 
Answer & Explanation Answer: B) -1

Explanation:

It returns -1

Report Error

View Answer Report Error Discuss

Filed Under: Programming

1 2936
Q:

Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix Notation

Answer

Prefix Notation:


^ - * +ABC - DE + FG

Report Error

View answer Workspace Report Error Discuss

Subject: Programming

1 2211
Q:

Methods declared as what cannot be overriden?

A) Transcient B) Abstract
C) Final D) Super
 
Answer & Explanation Answer: C) Final

Explanation:

Once a method declared as Final cannot be  overriden

Report Error

View Answer Report Error Discuss

Filed Under: Programming

0 3405
Q:

Which of the following is true?

A) It is appropriate to use assertions to validate arguments to methods marked public B) It is appropriate to catch and handle assertion errors
C) It is NOT appropriate to use assertions to validate command-line arguments D) None
 
Answer & Explanation Answer: C) It is NOT appropriate to use assertions to validate command-line arguments

Explanation:

A is incorrect. It is acceptable to use assertions to test the arguments of private methods.

 

B is incorrect. While assertion errors can be caught, Sun discourages you from doing so.

Report Error

View Answer Report Error Discuss

Filed Under: Programming

0 3543
Q:

Which of the following statement is true?

A) Cohesion is the OO principle most closely associated with hiding implementation details B) Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs
C) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose D) None
 
Answer & Explanation Answer: C) Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose

Explanation:

A refers to encapsulation, B refers to coupling

Report Error

View Answer Report Error Discuss

Filed Under: Programming

4 15374
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 & Explanation 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

Report Error

View Answer Report Error Discuss

Filed Under: Programming

6 60091