Programming Languages: Delphi, C, and Java

A mixed quiz covering concepts from Delphi/Pascal, C programming, and Java including components, memory management, operators, pointers, and GUI programming

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Default layout for frame

  1. Flow Layout
  2. GridLayout
  3. Card Layout
  4. BorderLayout
  5. GridBagLayout
Question 2 True/False

Check whether the syntax of the piece of code is correct: text.setBackGround(color.Yellow);

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

Code: FILE *f = fopen( fileName, "r" ); readData( f ); if( ???? ) { puts( "End of file was reached" ); } Which one of the following can replace the ???? in the code above to determine if the end of a file has been reached?

  1. f == EOF
  2. feof( f )
  3. eof( f )
  4. f == NULL
Question 4 Multiple Choice (Single Answer)

Which one of the following statements allocates enough space to hold an array of 10 integers that are initialized to 0?

  1. int *ptr = (int *) malloc(10, sizeof(int));
  2. int *ptr = (int *) calloc(10, sizeof(int));
  3. int *ptr = (int ) malloc(10sizeof(int));
  4. int *ptr = (int ) alloc(10sizeof(int));
Question 5 Multiple Choice (Single Answer)

Which one of the following C operators is right associative?

  1. =
  2. ,
  3. []
  4. ->
Question 6 Multiple Choice (Single Answer)

Code: #include <stdio.h> int i; void increment( int i ) { i++; } int main() { for( i = 0; i < 10; increment( i ) ) { } printf("i=%d\n", i); return 0; } What will happen when the program above is compiled and executed?

  1. It will not compile.
  2. It will print out: i=9.
  3. It will print out: i=10.
  4. It will loop indefinitely
Question 7 Multiple Choice (Single Answer)

char ** array [12][12][12]; Consider array, defined above. Which one of the following definitions and initializations of p is valid?

  1. char ** (* p) [12][12] = array;
  2. char ***** p = array;
  3. char * (* p) [12][12][12] = array;
  4. const char ** p [12][12][12] = array;
Question 8 Multiple Choice (Single Answer)

Code: char *ptr; char myString[] = "abcdefg"; ptr = myString; ptr += 5; What string does ptr point to in the sample code above?

  1. efg
  2. cdefg
  3. fg
  4. None of the above
Question 9 Multiple Choice (Single Answer)

time_t t; Which one of the following statements will properly initialize the variable t with the current time from the sample above

  1. t = ctime();
  2. time( &t );
  3. t = localtime();
  4. t = clock();
Question 10 Multiple Choice (Single Answer)

Code: char* myFunc (char *ptr) { ptr += 3; return (ptr); } int main() { char *x, *y; x = "HELLO"; y = myFunc (x); printf ("y = %s \n", y); return 0; } What will print when the sample code above is executed?

  1. y = LLO
  2. y = LO
  3. y = ELLO
  4. y = HELLO
Question 11 Multiple Choice (Single Answer)

int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What number will z in the sample code above contain?

  1. 12
  2. 10
  3. 11
  4. 6
Question 12 Multiple Choice (Single Answer)

What number is equivalent to -4e3?

  1. -400
  2. .004
  3. -4000
  4. .0004
Question 13 Multiple Choice (Single Answer)

Which one of the following is not written in Delphi?

  1. Skype
  2. Toad
  3. PL/SQL Developer
  4. MySQL
  5. MySQL Administrator
Question 14 Multiple Choice (Single Answer)

Find out the odd one.

  1. Embarcadero
  2. CodeGear
  3. Inprise
  4. Borland
  5. Pascal
Question 15 Multiple Choice (Single Answer)

Which compiler directive controls whether the reserved word 'string' represents a short string or a long string?

  1. $M+/-
  2. $H+/-
  3. $P+/-
  4. $V+/-
  5. $X+/-
Question 16 Multiple Choice (Single Answer)

Ultimate base class of all Objects and Components.

  1. TObect
  2. TUnknown
  3. IUnknown
  4. TBase
  5. TComponent
Question 17 Multiple Choice (Single Answer)

Components can only be allocated on the -----

  1. Stack
  2. Heap
  3. Register
  4. Floppy
  5. Compact Disk
Question 18 Multiple Choice (Single Answer)

Property can be pass as a var parameters. Judge the statement.

  1. TRUE
  2. True using pointer
  3. FALSE
  4. Some times true, some times false.
Question 19 Multiple Choice (Single Answer)

What is the ordinal value of 'nodefault' storage specifier of a property?

  1. 2147483647
  2. -2147483647
  3. 0
  4. 2147483648
  5. -1
Question 20 Multiple Choice (Single Answer)

TButton caption can be left aligned. Judge the comment.

  1. TRUE
  2. FALSE
  3. True with the help of changing the Bidi alignment.
  4. True by setting proper margin value.