Tag: programming languages

Questions Related to programming languages

  1. It is an instance method of Object class.

  2. It is a static method of the Object class

  3. It is an instance method of Thread class.

  4. The Thread must have a lock on the object on which the wait() method is to be invoked

  5. An object can have only one Thread in a waiting state at a time

  6. It must be called in a synchronized code


Correct Option: A,D,F

Which of the following statements are true about synchronization? choose two

  1. Static methods cannot be synchronized

  2. Synchronized methods cannot make calls to non-synchronized methods

  3. A synchronized method can be overridden to be non-synchronized and vice versa

  4. When a thread is executing a synchronized method, other threads can freely access non-synchronized methods of the same object


Correct Option: C,D

void Free( struct node *ptr ) { while( ptr) { ???? } } Which one of the following can replace the ???? for the function above to release the memory allocated to a linked list?

  1. n = n->next; free( n );

  2. struct node m = n; n = n->next; free( m );

  3. free( n ); n = n->next;

  4. struct node m = n; free( m ); n = n->next;


Correct Option: B

int n = 0; for ( ; ; ) { if (n++ == 5) break; continue; } printf("x=%d\n", x); What will be printed when the sample code above is executed?

  1. 1

  2. 2

  3. 4

  4. 6


Correct Option: D

struct customer *p= malloc( sizeof( struct customer ) ); Given the sample allocation for the pointer "p" found above, which one of the following statements is used to reallocate ptr to be an array of 10 elements?

  1. p = realloc( ptr, 10 * sizeof( struct ritesh));

  2. realloc( ptr, 9 * sizeof( struct ritesh) );

  3. p+= malloc( 9 * sizeof( struct ritesh) );

  4. p = realloc( ptr, 9 * sizeof( struct ritesh) );


Correct Option: A
  1. int *p; *p = 0x200;

  2. int *p = &0x200;

  3. int *p = *0x200;

  4. int *p = 0x200;


Correct Option: A

Sockets provide an interface for programming networks in which layer?

  1. Application

  2. Network

  3. Transport

  4. Physical


Correct Option: C

Socket – based communication is programming language independent.

  1. True

  2. False


Correct Option: A

Using which class,A server can be implemented?

  1. Server in java.net package

  2. ServerSocket in java.util.package

  3. Server in java.util package

  4. ServerSocket in java.net package


Correct Option: D