0

web technology Online Quiz - 118

Description: web technology Online Quiz - 118
Number of Questions: 20
Created by:
Tags: web technology
Attempted 0/20 Correct 0 Score 0

Given: 3. public class Wind { 4. public static void main(String[] args) { 5. foreach: 6. for(int j=0; j<5; j++) { 7. for(int k=0; k< 3; k++) { 8. System.out.print(" " + j); 9. if(j==3 && k==1) break foreach; 10. if(j==0 || j==2) break; 11. } 12. } 13. } 14. } What is the result?

  1. 0 1 2 3

  2. 1 1 1 3 3

  3. 0 1 1 1 2 3 3

  4. 1 1 1 3 3 4 4 4

  5. 0 1 1 1 2 3 3 4 4 4

  6. Compilation fails


Correct Option: C

AI Explanation

To answer this question, let's go through each option and determine if it is correct or incorrect:

Option A) 0 1 2 3 - This option is incorrect. The output does not include the number 2.

Option B) 1 1 1 3 3 - This option is incorrect. The output does not include the number 2.

Option C) 0 1 1 1 2 3 3 - This option is correct.

Explanation:

  • The outer for loop iterates from 0 to 4 (j=0,1,2,3,4).
  • The inner for loop iterates from 0 to 2 (k=0,1,2).
  • The line System.out.print(" " + j) prints the current value of j.
  • The line if(j==3 &amp;&amp; k==1) break foreach checks if j is equal to 3 and k is equal to 1. If this condition is true, the program breaks out of the outer for loop using the label "foreach".
  • The line if(j==0 || j==2) break checks if j is equal to 0 or j is equal to 2. If this condition is true, the program breaks out of the inner for loop.
  • The program prints the value of j for each iteration of the inner for loop.
  • The program stops printing when j is equal to 3 and k is equal to 1, which is why the number 2 is not printed.
  • The final output is "0 1 1 1 2 3 3".

Option D) 1 1 1 3 3 4 4 4 - This option is incorrect. The output does not include the number 0.

Option E) 0 1 1 1 2 3 3 4 4 4 - This option is incorrect. The output does not include the number 4.

Option F) Compilation fails - This option is incorrect. There are no syntax errors in the given code.

The correct answer is Option C) 0 1 1 1 2 3 3. This option is correct because it accurately represents the output of the given code.

Given: 3. public class TestDays { 4. public enum Days { MON, TUE, WED }; 5. public static void main(String[] args) { 6. for(Days d : Days.values() ) 7. ; 8. Days [] d2 = Days.values(); 9. System.out.println(d2[2]); 10. } 11. } What is the result? (Choose all that apply.)

  1. TUE

  2. Wed

  3. The output is unpredictable

  4. Compilation fails due to an error on line 4

  5. Compilation fails due to an error on line 6

  6. Compilation fails due to an error on line 8


Correct Option: B

AI Explanation

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

Option A) TUE - This option is incorrect because the output is not TUE.

Option B) Wed - This option is correct because the output will be "Wed".

Option C) The output is unpredictable - This option is incorrect because the output is predictable and will be "Wed".

Option D) Compilation fails due to an error on line 4 - This option is incorrect because there is no error on line 4. Line 4 declares an enum called "Days" with the values MON, TUE, and WED.

Option E) Compilation fails due to an error on line 6 - This option is incorrect because there is no error on line 6. Line 6 is a for-each loop that iterates over the values of the enum "Days".

Option F) Compilation fails due to an error on line 8 - This option is incorrect because there is no error on line 8. Line 8 creates an array "d2" and assigns the values of the enum "Days" to it.

The correct answer is B) Wed. This option is correct because the line 9 prints the value at index 2 of the array "d2", which corresponds to "Wed".

Given the proper import statement(s), and 13. PriorityQueue pq = new PriorityQueue(); 14. pq.add("2"); 15. pq.add("4"); 16. System.out.print(pq.peek() + " "); 17. pq.offer("1"); 18. pq.add("3"); 19. pq.remove("1"); 20. System.out.print(pq.poll() + " "); 21. if(pq.remove("2")) System.out.print(pq.poll() + " "); 22. System.out.println(pq.poll() + " " + pq.peek()); What is the result?

  1. 2 2 3 3

  2. 2 2 3 4

  3. 4 3 3 4

  4. 2 2 3 3 3

  5. 4 3 3 3 3

  6. 2 2 3 3 4


Correct Option: B

AI Explanation

To answer this question, let's go through each line of code and analyze the output:

Line 13: Creates a PriorityQueue object pq of type String.

Line 14: Adds the element "2" to the PriorityQueue pq.

Line 15: Adds the element "4" to the PriorityQueue pq.

Line 16: Prints the element at the front of the PriorityQueue using the peek() method. The element at the front is "2".

Line 17: Adds the element "1" to the PriorityQueue pq using the offer() method.

Line 18: Adds the element "3" to the PriorityQueue pq.

Line 19: Removes the element "1" from the PriorityQueue pq.

Line 20: Prints and removes the element at the front of the PriorityQueue using the poll() method. The element at the front is "2".

Line 21: Checks if the element "2" can be removed from the PriorityQueue using the remove() method. Since it is present, the condition is true. It then prints and removes the element at the front of the PriorityQueue using the poll() method. The element at the front is "2".

Line 22: Prints and removes the element at the front of the PriorityQueue using the poll() method. The element at the front is "3". It also prints the element at the front of the PriorityQueue using the peek() method. The element at the front is "4".

Therefore, the result is "2 2 3 4".

The correct answer is B.

What is output to the web page on the second access to the same instance of the following JSP? (Choose one.) Chapter 6 Question 2

Chapter 6 Question 2

  1. 0

  2. 1

  3. 2

  4. 3

  5. 4

  6. Page does not translate.


Correct Option: D

In the UML notation a class can be represented by

  1. A rectangular box with the name of the class in the box

  2. A rectangular box with the name of the object, a : and the class name that the object belongs to

  3. A rectangular box with the class name prefixed by the word "class"

  4. A thin vertical line with key method calls shown as outward arrows

  5. A rectangular box with an inserted dashed box on the top right corner.


Correct Option: A

In the UML notation, an object can be represented by

  1. A comment or explanatory note associated with a class

  2. A rectangular box with the object name and the constraint "{object}" immediatly following it

  3. A rectangular box with the name of the object in the box.

  4. A rectangular box with the name of the object, a : and the class name that the object belongs to.

  5. A thin vertical line with key method calls shown as outward arrows .


Correct Option: D
  1. nesting of classes

  2. lines with a solid diamond at one end

  3. lines with a hollow diamond at one end

  4. lines with a triangular arrow at one end

  5. lines with a triangular arrow at both ends


Correct Option: D
  1. getSessionBehaviour()

  2. getApplicationId()

  3. getSecurityLevel()

  4. getServletName()


Correct Option: B
  1. Write name here

  2. Write name here

  3. Write name here

  4. Write name here


Correct Option: A

The file where the context root of the application is specified

  1. Web.xml

  2. application.xml

  3. ps.xml

  4. Actionconfig.xml


Correct Option: B
  1. a time-line illustrating a typical sequence of calls between object function members

  2. a call tree illustrating all possible sequences of calls between class function members

  3. a time-line illustrating the changes in inheritance and instantiation relationships between classes and objects over time

  4. a tree illustrating inheritance and relationships between classes

  5. a directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects


Correct Option: A

In the UML notation, inside each class in a class diagram are printed

  1. its name, attributes, operations, and derived classes.

  2. its name, attributes and operations.

  3. its name, and attributes.

  4. its name, and operations.

  5. just its name.


Correct Option: B

Key elements of the use-case diagram are:

  1. people, computers

  2. actors, use-cases

  3. people, classes, and objects

  4. uses, cases

  5. scenarios in point form


Correct Option: B

Aggregation (encapsulation) relationships are represented in the UML notation by

  1. nesting of classes

  2. lines with a solid diamond at one end

  3. lines with a hollow diamond at one end

  4. lines with an arrow at one end

  5. lines without an arrow at either end


Correct Option: C

In which file will the servlets and the security roles of the application will be defined

  1. Web.xml

  2. application.xml

  3. ps.xml

  4. Actionconfig.xml


Correct Option: A

Where does the application been first taken in to, when an URL is hit in the browser

  1. Servlet of the appilcation

  2. Deployment descriptor of the appln

  3. Context root of the application

  4. ps.xml file of the application


Correct Option: B

In the UML notation, parameterized (generic) classes are represented by

  1. the normal class representation with a dotted arrow pointing at the template parameter classes

  2. the normal class representation but shaded grey.

  3. the normal class representation with a dotted outline and the names of its parameter classes listed on the top right-hand corner.

  4. the normal class representation with a rectangular box in its top left-hand corner.

  5. Its a trick question - parameterized classes can't be specified in the UML notation.


Correct Option: C
- Hide questions