0
Alien head

programming languages Online Quiz - 254

Description: programming languages Online Quiz - 254
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

What is the result of compiling and running the following code ? 1. StringBuffer s1=new StringBuffer("hello"); 2. StringBuffer s2=new StringBuffer("hello"); 3. Float f1=9.0F; 4. Double f2=9.0; 5. System.out.print(f1.equals(f2)); 6. System.out.print(s1==s2); 7. System.out.print(s1.equals(s2));

  1. Prints "truetruetrue"

  2. Prints "falsefalsetrue"

  3. Prints "falsefalsefalse"

  4. Compiler error on line 5

  5. Compiler error on line 7

  6. None


Correct Option: B

What is the result of compiling and running the following program? import java.util.Formatter; class Format2 { public static void main(String[] args) { String s="hello123"; Formatter f=new Formatter(); f.format("%S",s); System.out.println(f); } }

  1. Prints "hello123"

  2. Prints "HELLO123"

  3. Compiler error

  4. IllegalFormatException


Correct Option: B

Iterator for a collection will update along with the collection, when it is modified and give the updated one while traversing.

  1. True

  2. False


Correct Option: B

Which of the following does not guarantee the order of data storage will be constant over a period of time?

  1. HashMap

  2. ArrayList

  3. Stack

  4. Queue


Correct Option: A

Main is the only thread that runs when a Java program is started?

  1. True

  2. False


Correct Option: B

What is the super class of Hashtable?

  1. Map

  2. HashMap

  3. Dictionary

  4. Vector


Correct Option: C

Which modifier tells JVM to avoid object persistence during serialization?

  1. final

  2. transient

  3. public

  4. private


Correct Option: B

Which algorithm is used in thread scheduling?

  1. Fixed Priority

  2. Round Robin

  3. Discrete Optimization

  4. None of the above


Correct Option: A

Which one of the following is not marker interface?

  1. Serializable

  2. Remote

  3. Cloneable

  4. List


Correct Option: D

The assigned port at the server can be obtained in the client side by

  1. getLocalPort() method

  2. getActivePort() method

  3. By pinging the server

  4. By giving value 0 as port number


Correct Option: A

If a client is run, when the server is not up

  1. Null Pointer Exception at client side

  2. Client will receive warning message

  3. ConnectException is thrown

  4. Compilation Error


Correct Option: C

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

Socket – based communication is programming language independent.

  1. True

  2. False


Correct Option: A

Sockets provide an interface for programming networks in which layer?

  1. Application

  2. Network

  3. Transport

  4. Physical


Correct Option: C

Which one of the following will declare a pointer to an integer at address 0x100 in memory?

  1. int *p; *p = 0x200;

  2. int *p = &0x200;

  3. int *p = *0x200;

  4. int *p = 0x200;


Correct Option: A

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

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

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

char * Name[] = { "Ritesh", "Kumar" "Singh", "Happy", "Bittoo" "Roshan", "Go", }; How many elements does the array dwarves (declared above) contain?

  1. 4

  2. 5

  3. 6

  4. 7


Correct Option: B

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
+ View questions