0

programming languages Online Quiz - 187

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

Trying determine the shape of a cylindrical can made from 1000 cm2 of tin that has the largest possible volume is an example of:

  1. Array calculation

  2. Text manipulation

  3. Optimization problem

  4. Object oriented programming


Correct Option: C

Final Inspection is done by

  1. Project leader

  2. GL

  3. Quality Reviewer

  4. Project Manager


Correct Option: C

Stateful session beans contain

  1. Home Interface

  2. Remote Interface

  3. Bean Class

  4. All the above


Correct Option: D

Which file contains the EJB modules of the application?

  1. .jar

  2. .war

  3. .ear

  4. .zip


Correct Option: C

What are the call back methods in Session bean?

  1. ejbCreate()

  2. ejbPassivate(),

  3. ejbActivate()

  4. All the above


Correct Option: D

JTA stands for

  1. Java Transaction Array

  2. Java Transaction API

  3. Java Translation Array

  4. Java Translation API


Correct Option: B

JTS stands for

  1. Java Transaction Service

  2. Java Translation Service

  3. Java Transaction Servlet

  4. Java Translation Servlet


Correct Option: A

Which one of the following is a valid declaration of an applet?

  1. Abstract class MyApplet extends java.applet.Applet {

  2. Public class MyApplet extends java.applet.Applet {

  3. Class MyApplet implements Applet {

  4. Public class MyApplet extends applet implements Runnable {


Correct Option: B

What are the JSP scripting elements?

  1. Declaration

  2. Scriplets

  3. Expressions

  4. All the above


Correct Option: D

What are the different types of JSP tags?

  1. Presentation Tag

  2. JSP standard Tag

  3. Custom tags

  4. All the above


Correct Option: D

int j; for(int i=0;i<14;i++) { if(i<10) { j = 2 + i; } System.out.println("j: " + j + " i: " + i); } What is WRONG with the above code?

  1. Integer "j" is not initialized.

  2. Nothing.

  3. You cannot declare integer i inside the for-loop declaration.

  4. The syntax of the "if" statement is incorrect.


Correct Option: B
Explanation:

To solve this question, the user should have knowledge of basic Java syntax and control flow statements.

The code is a basic for-loop that initializes an integer variable i to 0 and then increments it by 1 with each iteration until it reaches 13. Inside the loop, there is an if statement that checks if i is less than 10. If it is, it initializes an integer variable j to 2 + i. Then, it prints out the values of j and i.

Now, let's go through each option and explain why it is right or wrong:

A. Integer "j" is not initialized: This option is incorrect. The integer "j" is initialized inside the for-loop. Although it is not initialized before the loop, it is initialized before it is used.

B. Nothing: This option is incorrect. There is something wrong with the code.

C. You cannot declare integer i inside the for-loop declaration: This option is incorrect. The declaration of integer i inside the for-loop is valid Java syntax.

D. The syntax of the "if" statement is incorrect: This option is incorrect. The syntax of the if statement in the code is correct.

Therefore, the correct answer is:

The Answer is: B

int values[] = {1,2,3,4,5,6,7,8}; for(int i=0;i< X; ++i) System.out.println(values[i]); Referring to the above, what value for X will print all members of array "values"?

  1. 1

  2. 7

  3. 8

  4. 9


Correct Option: C

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) X = 1 - This option is incorrect because if X is set to 1, the loop will only execute once and print the first member of the array, which is 1.

Option B) X = 7 - This option is incorrect because if X is set to 7, the loop will execute 7 times, but it will try to access the 8th member of the array, which is out of bounds. The array has indices from 0 to 7.

Option C) X = 8 - This option is correct because if X is set to 8, the loop will execute 8 times and print all the members of the array. The array has 8 members, and the loop will access indices from 0 to 7.

Option D) X = 9 - This option is incorrect because if X is set to 9, the loop will execute 9 times, but it will try to access the 9th member of the array, which is out of bounds. The array has indices from 0 to 7.

The correct answer is C) 8. This option is correct because setting X to 8 will print all the members of the array "values".

What are the two parts of a value of type double?

  1. significant digits

  2. length

  3. exponent

  4. Both & b


Correct Option: D

The following a legal Java statement

  1. m1 = new TextField("sixty");

  2. 1a = 6;

  3. add(m1);

  4. m1.setText("Hello world);


Correct Option: C

A function is:

  1. An entity that receives inputs and outputs

  2. A way of storing values

  3. A sequence of characters enclosed by quotes

  4. A kind of computer


Correct Option: A

What will happen if you attempt to compile and run the following code? Integer ten=new Integer(10); Long nine=new Long (9); System.out.println(ten + nine); int i=1; System.out.println(i + ten);

  1. 19 followed by 20

  2. 19 followed by 11

  3. Error: Can't convert java lang Integer

  4. 10 followed by 1


Correct Option: C

AI Explanation

To answer this question, let's go through each line of code and understand its behavior:

  1. Integer ten = new Integer(10); - This line creates a new instance of the Integer class and assigns the value 10 to it.

  2. Long nine = new Long(9); - This line creates a new instance of the Long class and assigns the value 9 to it.

  3. System.out.println(ten + nine); - This line attempts to print the sum of ten and nine. Since ten is an Integer and nine is a Long, the Java compiler will try to promote ten to a Long before performing the addition. However, this operation is not supported, and it will result in an error.

  4. int i = 1; - This line declares and initializes an integer variable i with the value 1.

  5. System.out.println(i + ten); - This line attempts to print the sum of i and ten. Since ten is an Integer and i is an int, the Java compiler will automatically promote i to an Integer before performing the addition. The sum will be 1 + 10 = 11, and it will be printed as the output.

Therefore, the correct answer is C. Error: Can't convert java lang Integer. The code will fail to compile because the addition of an Integer and a Long is not supported.

Which method takes the HttpServletRequest and HttpServletResponse objects as its arguments

  1. jspInit()

  2. jspDestroy()

  3. _jspService()

  4. None of the above


Correct Option: C

What JSP lifecycle methods can I override?

  1. jspInit()

  2. jspDestroy()

  3. _jspService()

  4. Both a & b


Correct Option: D

What does the following line of code mean? Double table[];

  1. table is a variable to refers to a real number

  2. table is a variable that refers to two numbers

  3. It is not legal Java code

  4. table is a variable that refers to an array


Correct Option: D

AI Explanation

To answer this question, let's go through the line of code:

Double table[];

This line of code declares a variable named table of type Double and specifies that it refers to an array of Double objects.

Option A) table is a variable that refers to a real number - This option is incorrect because Double in Java refers to a wrapper class for the primitive data type double, not a real number.

Option B) table is a variable that refers to two numbers - This option is incorrect because the code does not indicate that table refers to two numbers specifically. It simply declares a variable that can refer to an array.

Option C) It is not legal Java code - This option is incorrect because the code is valid Java syntax. It declares a variable of type Double array.

Option D) table is a variable that refers to an array - This option is correct because the line of code declares a variable named table that refers to an array. The [] syntax indicates that table is an array variable.

The correct answer is D) table is a variable that refers to an array.

The following is NOT an example of a data type.

  1. int

  2. public

  3. button

  4. void


Correct Option: B
- Hide questions