Tag: programming languages

Questions Related to programming languages

  1. A vector of arrays for a 2D geographic representation

  2. A class for containing unique array elements

  3. A class for containing unique vector elements

  4. An interface that ensures that implementing classes cannot contain duplicate keys


Correct Option: D
  1. The class can access any variable

  2. The class can only access static variables

  3. The class can only access transient variables

  4. The class can only access final variables


Correct Option: D
Explanation:

To answer this question, the user needs to know about nested classes and how they interact with the enclosing method.

When a class is defined inside a method, it is called a local inner class. The local inner class can access any final variables or effectively final variables of the enclosing method. An effectively final variable is a non-final variable whose value does not change after it is initialized.

The correct answer is:

D. The class can only access final variables

Option A is incorrect because the class cannot access any variable of the enclosing method, only final variables.

Option B is incorrect because the class cannot only access static variables of the enclosing method, only final variables.

Option C is incorrect because the class cannot only access transient variables of the enclosing method, only final variables.

Therefore, the correct answer is option D. The class can only access final variables of the enclosing method.

  1. System.gc();

  2. System.free();

  3. System.setGarbageCollection();

  4. System.out.gc();


Correct Option: A
  1. An exception is thrown if you attempt to add an element with a duplicate value

  2. The add method returns false if you attempt to add an element with a duplicate value

  3. A set may contain elements that return duplicate values from a call to the equals method

  4. Duplicate values will cause an error at compile time


Correct Option: B
  1. At the root of the collection hierarchy is a class called Collection

  2. The collection interface contains a method called enumerator

  3. The Set interface is designed for unique elements

  4. The interator method returns an instance of the Vector class


Correct Option: C

Which are features every EJB 2.0 container must implement or support? (Answer all that apply)

  1. A GUI bean deployment utility

  2. Transaction support for all bean types

  3. JNDI 1.2 name space

  4. Remote client views for all bean types


Correct Option: B,C
  1. A Portable finder query text

  2. Container managed persistence

  3. Local interfaces for session beans

  4. XML based deployment descriptors


Correct Option: A,B,C,D
  1. Relationships can be one-to-one, one-to-many or many-to-many

  2. A get method return type can use java.util.map

  3. A remote interface is required for such a bean to have bi-directional relationship with another entity bean

  4. Such a bean can have relationships with only message-driven beans


Correct Option: A