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

Inheritance 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 a triangular arrow at one end

  5. lines with a triangular arrow at both ends


Correct Option: D

AI Explanation

To answer this question, you need to understand how inheritance relationships are represented in UML (Unified Modeling Language) notation.

Option A) Nesting of classes - This option is incorrect because nesting of classes represents a composition relationship, not an inheritance relationship.

Option B) Lines with a solid diamond at one end - This option is incorrect because lines with a solid diamond at one end represent an aggregation relationship, not an inheritance relationship.

Option C) Lines with a hollow diamond at one end - This option is incorrect because lines with a hollow diamond at one end represent a composition relationship, not an inheritance relationship.

Option D) Lines with a triangular arrow at one end - This option is correct. Lines with a triangular arrow at one end represent an inheritance relationship in UML notation. The arrow points from the subclass (the class that inherits) to the superclass (the class being inherited from).

Option E) Lines with a triangular arrow at both ends - This option is incorrect. Lines with a triangular arrow at both ends represent an association relationship, not an inheritance relationship.

The correct answer is Option D. This option is correct because lines with a triangular arrow at one end represent an inheritance relationship in UML notation.

Mandatory Method(s) to be defined in servlets

  1. getSessionBehaviour()

  2. getApplicationId()

  3. getSecurityLevel()

  4. getServletName()


Correct Option: B

Which one of the following folder is mandatory to be defined to use the ps: custom tags

  1. TLDs

  2. DDLs

  3. Web-inf

  4. Meta-Inf


Correct Option: A

Which one is correct?

  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

An sequence diagram is

  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

AI Explanation

To answer this question, you need to understand what a sequence diagram is and what it represents.

Option A) A time-line illustrating a typical sequence of calls between object function members - This option is correct. A sequence diagram is a visual representation of the interactions between objects in a system. It shows the sequence of messages exchanged between objects, typically illustrating the flow of control and communication between object function members.

Option B) A call tree illustrating all possible sequences of calls between class function members - This option is incorrect. A call tree represents all possible call paths in a program, but it is not specific to class function members. It does not capture the sequence of calls between objects.

Option C) A time-line illustrating the changes in inheritance and instantiation relationships between classes and objects over time - This option is incorrect. While a sequence diagram may show the interactions between classes and objects, it does not explicitly illustrate changes in inheritance and instantiation relationships over time.

Option D) A tree illustrating inheritance and relationships between classes - This option is incorrect. A tree diagram can represent inheritance and relationships between classes, but it does not capture the sequence of calls between object function members.

Option E) A directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects - This option is incorrect. A directed acyclic graph can represent inheritance and instantiation relationships, but it does not capture the sequence of calls between object function members.

The correct answer is A) a time-line illustrating a typical sequence of calls between object function members. This option is correct because a sequence diagram visually represents the order of messages exchanged between objects, showing the sequence of calls between object function members.

  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
  1. people, computers

  2. actors, use-cases

  3. people, classes, and objects

  4. uses, cases

  5. scenarios in point form


Correct Option: B
  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
  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
  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