Tag: technology

Questions Related to technology

  1. This code is NOT thread-safe

  2. The programmer can replace StringBuffer with StringBuilder with no other changes

  3. This code will perform poorly. For better performance, the code should be rewritten:return "";

  4. This code will perform well and converting the code to use StringBuilder will not enhance the performance


Correct Option: B
  1. Inheritance represents an is-a relationship

  2. Inheritance represents a has-a relationship

  3. Interfaces must be used when creating a has-a relationship

  4. Instance variables can be used when creating a has-a relationship.


Correct Option: A,D
  1. Compilation fails because of an error in line 3

  2. Compilation fails because of an error in line 7

  3. Compilation fails because of an error in line 9

  4. If you define D e = new E(), then e.bMethod() invokes the version of bMethod() defined in Line 5.

  5. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 5.

  6. If you define D e = (D)(new E()), then e.bMethod() invokes the version of bMethod() defined in Line 9.


Correct Option: F