0

programming languages Online Quiz - 147

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

Which implicit object can access the attributes from the ServletContext?

  1. Server

  2. Request

  3. Application

  4. Context


Correct Option: C

When declaring a listener in the DD, which sub-element of the element are required?


Correct Option: A

Which most closely matches a description of a Java Map?

  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

AI Explanation

To answer this question, you need to understand the concept of a Java Map.

Option A) A vector of arrays for a 2D geographic representation - This option is incorrect because a Java Map is not specifically designed for representing 2D geographic data.

Option B) A class for containing unique array elements - This option is incorrect because a Java Map is not specifically designed for containing array elements.

Option C) A class for containing unique vector elements - This option is incorrect because a Java Map is not specifically designed for containing vector elements.

Option D) An interface that ensures that implementing classes cannot contain duplicate keys - This option is correct because a Java Map is an interface that ensures that implementing classes cannot contain duplicate keys. In other words, a Java Map is a data structure that stores key-value pairs and guarantees that each key is unique.

The correct answer is Option D.

For a class defined inside a method, what rule governs access to the variables of the enclosing method?

  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.

Which of the following is the correct syntax for suggesting that the JVM performs garbage collection

  1. System.gc();

  2. System.free();

  3. System.setGarbageCollection();

  4. System.out.gc();


Correct Option: A

AI Explanation

To answer this question, you need to understand how garbage collection works in Java.

Garbage collection in Java is an automatic process performed by the Java Virtual Machine (JVM) to reclaim memory occupied by objects that are no longer in use. The JVM decides when to perform garbage collection based on factors like available memory and CPU usage.

The correct syntax for suggesting that the JVM performs garbage collection is:

A) System.gc();

Option A is correct because System.gc() is a method that suggests to the JVM to perform garbage collection. However, it is important to note that calling this method does not guarantee immediate garbage collection. The JVM will decide whether and when to perform garbage collection based on its internal algorithms.

Now, let's go through the other options to understand why they are incorrect:

B) System.free(); Option B is incorrect because there is no System.free() method in Java. This method does not exist in the Java API.

C) System.setGarbageCollection(); Option C is incorrect because there is no System.setGarbageCollection() method in Java. This method does not exist in the Java API.

D) System.out.gc(); Option D is incorrect because System.out.gc() is not a valid syntax to suggest garbage collection in Java. The System.out is used for standard output, and the gc() method does not exist in the System.out class.

Therefore, the correct answer is A) System.gc().

How does the set collection deal with duplicate elements?

  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

Which of the following statements are true?

  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

AI Explanation

To answer this question, let's go through each statement to determine if it is true or false:

A. At the root of the collection hierarchy is a class called Collection - This statement is false. The root of the collection hierarchy is the java.lang.Object class, not the Collection class.

B. The collection interface contains a method called enumerator - This statement is false. The Collection interface does not contain a method called enumerator. However, it does contain a method called iterator which returns an iterator over the elements in the collection.

C. The Set interface is designed for unique elements - This statement is true. The Set interface in Java is designed for collections that contain unique elements. Each element in a Set must be unique, and duplicate elements are not allowed.

D. The iterator method returns an instance of the Vector class - This statement is false. The iterator method in the Collection interface does not return an instance of the Vector class. Instead, it returns an instance of the Iterator interface, which is used to iterate over the elements in a collection.

The correct answer is C. The Set interface is designed for unique elements.

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

Which are the features in EJB 2.0?

  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

Whats true for an entity bean provider using container-manaaged persistent relationship?

  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

When a remote client invokes a method on an entity bean using container managed persistence, and that bean has already been removed, what exception will be thrown?

  1. javax.ejb.AccessLocalException

  2. javax.rmi.NoSuchObjectException

  3. javax.ejb.NoSuchEntityException

  4. javax.rmi.StubNotFoundException


Correct Option: B

Given content-managed unidirectional relationship: Foo(0-1) -> Bar(0-1) And the object relations: f1 -> b1 f2 -> b2 What will be true after the following code runs? f2.setBar(f1.getBar());

  1. f1.getBar() ==null

  2. b2.getFoo == null

  3. b1.getFoo == null

  4. none of the above


Correct Option: A,B

Whats true about EJB QL queries?

  1. The SELECT clause designates query domain

  2. An EJB QL query may have parameters.

  3. The WHERE clause determines the types of objects to be selected

  4. Of the three clause types, SELECT, FROM and WHERE, only the SELECT clause is required


Correct Option: B

Given the EJB QL Expression: p.discount BETWEEN 10 AND 15 Which expression is equivalent?

  1. p.discount > 10 AND p.discount < 15

  2. p.discount >= 10 AND p.discount < 15

  3. p.discount >= 10 AND p.discount <= 15

  4. p.discount > 10 AND p.discount <= 15


Correct Option: C

data student; input sno sname $ marks; datalines; 10 suganya 30 20 preethi 40 30 rathna 40 nitya 50 manasa ; run; The output dataset student contains the following records

  1. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40} {. .}

  2. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40}

  3. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna } {40 nitya} {50 manasa}

  4. sno sname marks { 10 suganya 30} {20 preethi 40}


Correct Option: B

AI Explanation

To answer this question, let's understand the given code and its output.

The code defines a SAS dataset named "student" with three variables: "sno" (student number), "sname" (student name), and "marks" (student marks). The "input" statement is used to read the data values for each variable. The "datalines" statement is used to specify the input data values.

Based on the given input data values, the "student" dataset will contain the following records:

A. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40} {. .} B. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40} C. sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna } {40 nitya} {50 manasa} D. sno sname marks { 10 suganya 30} {20 preethi 40}

Let's go through each option to determine the correct answer:

Option A) sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40} {. .} - This option is incorrect because it includes an additional record with missing values for "sno", "sname", and "marks".

Option B) sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna 40} - This option is correct because it includes all the given records without any missing values.

Option C) sno sname marks { 10 suganya 30} {20 preethi 40} {30 rathna } {40 nitya} {50 manasa} - This option is incorrect because it includes additional records with missing values for "marks".

Option D) sno sname marks { 10 suganya 30} {20 preethi 40} - This option is incorrect because it does not include all the given records.

Therefore, the correct answer is B. The "student" dataset contains the records { 10 suganya 30}, {20 preethi 40}, {30 rathna 40}.

data flower; Length x $ 5 y $ 11; input x y; datalines; daisyyellow ; run; What is the value of x and y in the output dataset?

  1. NO Observations

  2. x=daisy y=missing

  3. x = daisy y=daisyyellow

  4. x = daisy y=w


Correct Option: A

data state; input name $ @; if name = 'TN' then input famous $; else input lang $; input capital $; datalines; TN food chennai AP telugu hyderabad ; run; The no of times that the input is done for each iteration

  1. 2

  2. 1

  3. 3

  4. 4


Correct Option: A

data new(Keep x y); set old; run; What is the result?

  1. The new dataset will have only variables x and y

  2. Syntax Error.The Keep statement should be (Keep = x y).

  3. The old dataset will have only variables x and y

  4. The new dataset will have all variables


Correct Option: B

proc format; value score. 1-10 = 'High' 11-20 = 'Low' ; run; What is true about this statement?

  1. Format score is created in the SAS catalog

  2. The format name should not end with .

  3. The format can be used in DATA steps

  4. The format can be used in PROC steps


Correct Option: B

data str; x='My name is myuri'; a=find(X,'MY','i',-3); run; What is the value of a?

  1. 1

  2. 12

  3. 10

  4. 2


Correct Option: A
- Hide questions