0

web technology Online Quiz - 120

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

XML is Case-Sensitive Language

  1. True

  2. False


Correct Option: B
  1. The before() method will print 1 2

  2. The before() method will print 1 2 3

  3. The before() method will print three numbers, but the order cannot be determined

  4. The before() method will not compile

  5. The before() method will throw an exception at runtime


Correct Option: E
  1. Change the Carnivore interface to interface Carnivore extends Hungry {}

  2. Change the Herbivore interface to interface Herbivore extends Hungry {}

  3. Change the Sheep class to class Sheep extends Animal implements Herbivore { public void munch(Grass x) {} }

  4. Change the Sheep class to class Sheep extends Plant implements Carnivore { public void munch(Wolf x) {} }

  5. Change the Wolf class to class Wolf extends Animal implements Herbivore { public void munch(Grass x) {} }

  6. No changes are necessary


Correct Option: B

Which collection class(es) allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized? (Choose all that apply.)

  1. java.util.HashSet

  2. java.util.LinkedHashSet

  3. java.util.List

  4. java.util.ArrayList

  5. java.util.Vector

  6. java.util.PriorityQueue


Correct Option: D

AI Explanation

To answer this question, you need to understand the characteristics of different collection classes in Java. Let's go through each option to understand which class(es) allow you to grow or shrink its size and provide indexed access to its elements, without being synchronized:

Option A) java.util.HashSet - This class does not provide indexed access to its elements.

Option B) java.util.LinkedHashSet - This class does not provide indexed access to its elements.

Option C) java.util.List - The List interface allows you to grow or shrink its size and provides indexed access to its elements. However, this option does not specify a specific implementation of the List interface.

Option D) java.util.ArrayList - This class allows you to grow or shrink its size and provides indexed access to its elements. The methods of ArrayList are not synchronized.

Option E) java.util.Vector - This class allows you to grow or shrink its size and provides indexed access to its elements. However, the methods of Vector are synchronized, so it does not meet the requirement of not having synchronized methods.

Option F) java.util.PriorityQueue - This class does not provide indexed access to its elements.

The correct answer is D) java.util.ArrayList. This class allows you to grow or shrink its size and provides indexed access to its elements, without the methods being synchronized.

Which is true? (Choose all that apply.)

  1. "X extends Y" is correct if and only if X is a class and Y is an interface

  2. "X extends Y" is correct if and only if X is an interface and Y is a class

  3. "X extends Y" is correct if X and Y are either both classes or both interfaces

  4. "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces


Correct Option: C

AI Explanation

To answer this question, we need to understand the concept of inheritance in object-oriented programming.

In object-oriented programming, the keyword "extends" is used to establish an inheritance relationship between classes and interfaces. Here are the explanations for each option:

Option A) "X extends Y" is correct if and only if X is a class and Y is an interface. This option is incorrect. In Java, a class can extend another class or implement an interface. The keyword "extends" is used for class inheritance, while the keyword "implements" is used for interface implementation.

Option B) "X extends Y" is correct if and only if X is an interface and Y is a class. This option is incorrect. In Java, an interface cannot extend a class. It can only extend another interface using the keyword "extends".

Option C) "X extends Y" is correct if X and Y are either both classes or both interfaces. This option is correct. In Java, a class can extend another class, and an interface can extend another interface. Therefore, "X extends Y" is correct if X and Y are either both classes or both interfaces.

Option D) "X extends Y" is correct for all combinations of X and Y being classes and/or interfaces. This option is incorrect. As explained above, "X extends Y" is not correct for all combinations. It is only correct if X and Y are either both classes or both interfaces.

Therefore, the correct answer is option C.

Given: 3. class A { } 4. class B extends A { } 5. public class ComingThru { 6. static String s = "-"; 7. public static void main(String[] args) { 8. A[] aa = new A[2]; 9. B[] ba = new B[2]; 10. sifter(aa); 11. sifter(ba); 12. sifter(7); 13. System.out.println(s); 14. } 15. static void sifter(A[]... a2) { s += "1"; } 16. static void sifter(B[]... b1) { s += "2"; } 17. static void sifter(B[] b1) { s += "3"; } 18. static void sifter(Object o) { s += "4"; } 19. } What is the result?

  1. -124

  2. -134

  3. -424

  4. -434

  5. -444

  6. Compilation fails


Correct Option: D

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

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

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

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
  1. Write name here

  2. Write name here

  3. Write name here

  4. Write name here


Correct Option: A
  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.

Option A) A time-line illustrating a typical sequence of calls between object function members - This option is correct. A sequence diagram is a type of interaction diagram in UML that represents the interactions between objects in a system. It shows the sequence of messages or method calls between objects in a time-ordered manner.

Option B) A call tree illustrating all possible sequences of calls between class function members - This option is incorrect. A call tree is a different type of diagram that represents the hierarchy of method calls in a program. It is not specifically used to illustrate sequences of calls between class function members.

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 can show interactions between objects, it does not specifically illustrate changes in inheritance and instantiation relationships between classes and objects.

Option D) A tree illustrating inheritance and relationships between classes - This option is incorrect. A sequence diagram does not typically illustrate inheritance and relationships between classes. It focuses on interactions between objects.

Option E) A directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects - This option is incorrect. While a directed acyclic graph can be used to represent inheritance and instantiation relationships, it is not specifically used to create sequence diagrams.

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 represents the sequence of messages or method calls between objects in a time-ordered manner.

- Hide questions