0

web technology Online Quiz - 117

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

In which file will the server side validations will be handled

  1. Page Handler

  2. Action Controller

  3. JSP

  4. Javascript


Correct Option: A

Where will the Life Host region of the server be mentioned

  1. ec_debug.jsp->Configuration->DomainData->LifeHost

  2. ec_debug.jsp->DomainData->Host.xml

  3. using wasops

  4. ec_debug->Jars->Registered Components->DomainData->Host


Correct Option: A

Given: public static void before() { Set set = new TreeSet(); set.add("2"); set.add(3); set.add("1"); Iterator it = set.iterator(); while (it.hasNext()) System.out.print(it.next() + " "); } Which statements are true?

  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

AI Explanation

To answer this question, let's analyze the given code:

public static void before() {
    Set set = new TreeSet();
    set.add("2");
    set.add(3);
    set.add("1");
    Iterator it = set.iterator();
    while (it.hasNext())
        System.out.print(it.next() + " ");
}

The code declares a TreeSet named set and adds three elements to it: "2", 3, and "1". It then creates an Iterator named it to iterate over the elements in the set. Finally, it prints each element followed by a space.

The elements in a TreeSet are ordered according to their natural ordering. In this case, the elements are of different types: "2" is a String, 3 is an Integer, and "1" is a String. The natural ordering of String objects is lexicographical (i.e., alphabetical), while the natural ordering of Integer objects is numerical.

Now let's go through each option:

Option A) The before() method will print 1 2 This option is incorrect because the elements in the set are ordered lexicographically, so "1" comes before "2".

Option B) The before() method will print 1 2 3 This option is incorrect because the elements in the set are ordered lexicographically, so "1" comes before "2" and "3" comes after "2".

Option C) The before() method will print three numbers, but the order cannot be determined This option is incorrect because the order of the elements in a TreeSet is determined by their natural ordering, which in this case can be determined.

Option D) The before() method will not compile This option is incorrect because the code does not contain any compilation errors.

Option E) The before() method will throw an exception at runtime This option is correct. The code tries to add elements of different types (String and Integer) to a TreeSet, which violates the requirement that all elements in a TreeSet must be of the same type. This will cause a ClassCastException to be thrown at runtime.

Therefore, the correct answer is E) The before() method will throw an exception at runtime.

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

Which architecture does PS framework follow

  1. Hibernate Architecture

  2. Struts Architecture

  3. MVC Architecture

  4. Web Architecture


Correct Option: C

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

AI Explanation

To answer this question, you need to understand how parameterized (generic) classes are represented in UML notation. Let's go through each option to understand why it is correct or incorrect:

Option A) The normal class representation with a dotted arrow pointing at the template parameter classes - This option is incorrect. In UML notation, a dotted arrow pointing at other classes typically represents an association or dependency relationship, not a parameterized class.

Option B) The normal class representation but shaded grey - This option is incorrect. In UML notation, shading is typically used to represent different levels of visibility or access, not to indicate a parameterized class.

Option C) The normal class representation with a dotted outline and the names of its parameter classes listed on the top right-hand corner - This option is correct. In UML notation, a parameterized class is represented by the normal class representation with a dotted outline and the names of its parameter classes listed on the top right-hand corner.

Option D) The normal class representation with a rectangular box in its top left-hand corner - This option is incorrect. In UML notation, a rectangular box in the top left-hand corner of a class is typically used to represent a stereotype, not a parameterized class.

Option E) It's a trick question - parameterized classes can't be specified in the UML notation - This option is incorrect. Parameterized classes can indeed be specified in UML notation using the representation mentioned in option C.

The correct answer is C. This option is correct because it accurately represents a parameterized (generic) class in UML notation.

Which of the following are true statements about the JavaServer Page life cycle? (Choose two.)

  1. The _jspService() method is called from the generated servlet's service() method.

  2. jspInit() is only ever called on the first request to a JSP instance.

  3. jspDestroy() is only ever called on the last request to a JSP instance.

  4. All servlet methods are accessible from the jspInit() method.

  5. You cannot override or provide a no-parameter init() method in a JSP page.


Correct Option: A,D

Which of the following techniques is likely to return an initialization parameter for a JSP page? (Choose two.)


Correct Option: B,D

What will be the result of pressing the submit button in the following HTML form? (Choose two.)

  1. A request is sent with the HTTP method HEAD.

  2. A request is sent with the HTTP method POST.

  3. A request is sent with the HTTP method GET.

  4. The parameter fullName is the only parameter passed to the web server in the request URL.

  5. The parameters fullName and sbmButton are passed to the web server in the request URL.

  6. The parameter fullName is the only parameter passed to the web server as part of the request body.


Correct Option: C,F

Which of the following are valid servlet methods that match up with HTTP methods? (Choose four.)

  1. doGet()

  2. doPost()

  3. doConnect()

  4. doOptions()

  5. doHead()

  6. doRequest()


Correct Option: A,B,D,F

AI Explanation

To answer this question, you need to understand the relationship between servlet methods and HTTP methods.

In the Java Servlet API, there are several methods that correspond to different HTTP methods. These methods are used to handle requests from clients and provide appropriate responses. The commonly used methods are:

A. doGet() - This method is used to handle the GET requests. It retrieves information from the server and sends it back to the client.

B. doPost() - This method is used to handle the POST requests. It submits data to the server for processing.

C. doConnect() - This is not a valid servlet method. There is no HTTP method called CONNECT.

D. doOptions() - This method is used to handle the OPTIONS requests. It provides information about the communication options available for the requested resource.

E. doHead() - This method is used to handle the HEAD requests. It retrieves the headers of the response without the response body.

F. doRequest() - This is not a valid servlet method. There is no HTTP method called REQUEST.

Based on the above explanations, the valid servlet methods that match up with HTTP methods are A. doGet(), B. doPost(), D. doOptions(), and F. doRequest().

Therefore, the correct answer is A, B, D, F.

Which statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose all that apply.)

  1. If the equals() method returns true, the hashCode() comparison == might return false

  2. If the equals() method returns false, the hashCode() comparison == might return true

  3. If the hashCode() comparison == returns true, the equals() method must return true

  4. If the hashCode() comparison == returns true, the equals() method might return true

  5. If the hashCode() comparison != returns true, the equals() method might return true


Correct Option: B,D

AI Explanation

To answer this question, we need to understand the concepts of the equals() and hashCode() methods in Java.

The equals() method is used to compare two objects for equality. It is typically overridden to compare the values of the instance variables of the objects.

The hashCode() method is used to generate the hash code of an object. It is also typically overridden to generate a hash code based on the values of the instance variables.

Now, let's go through each option to understand why it is correct or incorrect:

Option A) If the equals() method returns true, the hashCode() comparison == might return false.

  • This option is incorrect. According to the contract between the equals() and hashCode() methods, if two objects are equal according to the equals() method, their hash codes must be equal as well. Therefore, the hashCode() comparison == should return true in this case.

Option B) If the equals() method returns false, the hashCode() comparison == might return true.

  • This option is correct. If two objects are not equal according to the equals() method, their hash codes can still be equal. This is because different objects can generate the same hash code, but it does not necessarily mean that they are equal.

Option C) If the hashCode() comparison == returns true, the equals() method must return true.

  • This option is incorrect. While it is true that equal objects must have equal hash codes, the reverse is not necessarily true. Two objects can have the same hash code, but their values may be different, resulting in the equals() method returning false.

Option D) If the hashCode() comparison == returns true, the equals() method might return true.

  • This option is correct. If two objects have the same hash code, it is possible that they are equal according to the equals() method. However, it is also possible that they are not equal.

Option E) If the hashCode() comparison != returns true, the equals() method might return true.

  • This option is incorrect. If two objects have different hash codes, it means that they are not equal according to the equals() method. The equals() method should always return false in this case.

Therefore, the correct answers are: B. If the equals() method returns false, the hashCode() comparison == might return true. D. If the hashCode() comparison == returns true, the equals() method might return true.

Given: import java.util.*; class MapEQ { public static void main(String[] args) { Map m = new HashMap(); ToDos t1 = new ToDos("Monday"); ToDos t2 = new ToDos("Monday"); ToDos t3 = new ToDos("Tuesday"); m.put(t1, "doLaundry"); m.put(t2, "payBills"); m.put(t3, "cleanAttic"); System.out.println(m.size()); } } class ToDos{ String day; ToDos(String d) { day = d; } public boolean equals(Object o) { return ((ToDos)o).day == this.day; } // public int hashCode() { return 9; } } Which is correct? (Choose all that apply.)

  1. As the code stands it will not compile

  2. As the code stands the output will be 2

  3. As the code stands the output will be 3

  4. If the hashCode() method is uncommented the output will be 2

  5. If the hashCode() method is uncommented the output will be 3

  6. If the hashCode() method is uncommented the code will not compile


Correct Option: C,D

AI Explanation

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

Option A) As the code stands, it will not compile - This option is incorrect. The code provided does compile without any errors.

Option B) As the code stands, the output will be 2 - This option is incorrect. The output will not be 2 because the equals() method in the ToDos class is not properly overridden.

Option C) As the code stands, the output will be 3 - This option is correct. The output will be 3 because the equals() method in the ToDos class is comparing the day field of the objects. Since t1 and t2 have the same value for day ("Monday"), they are considered equal, but they are distinct objects, so both of them are added to the map. Therefore, the map contains 3 entries: t1 -> "doLaundry", t2 -> "payBills", and t3 -> "cleanAttic".

Option D) If the hashCode() method is uncommented, the output will be 2 - This option is correct. If the hashCode() method is uncommented, the output will be 2 because the hashCode() method is used to determine the bucket in which to store the key-value pair in the HashMap. Since the hashCode() method is not overridden in the ToDos class, it uses the default implementation from the Object class, which generates a unique hash code for each object. As a result, t1 and t2 will generate different hash codes, and the map will consider them as distinct keys, resulting in only two entries: t2 -> "payBills" and t3 -> "cleanAttic".

Option E) If the hashCode() method is uncommented, the output will be 3 - This option is incorrect. If the hashCode() method is uncommented, the output will be 2 as explained in option D.

Option F) If the hashCode() method is uncommented, the code will not compile - This option is incorrect. Uncommenting the hashCode() method will not cause any compilation errors.

The correct answer is Option C and Option D. These options are correct because they accurately describe the behavior of the code provided.

Given: 12. public class AccountManager { 13. private Map accountTotals = new HashMap(); 14. private int retirementFund; 15. 16. public int getBalance(String accountName) { 17. Integer total = (Integer) accountTotals.get(accountName); 18. if (total == null) 19. total = Integer.valueOf(0); 20. return total.intValue(); 21. } 23. public void setBalance(String accountName, int amount) { 24. accountTotals.put(accountName, Integer.valueOf(amount)); 25. } 26. } This class is to be updated to make use of appropriate generic types, with no changes in behavior (for better or worse). Which of these steps could be performed? (Choose three.)

  1. Replace line 13 with private Map accountTotals = new HashMap();

  2. Replace line 13 with private Map accountTotals = new HashMap();

  3. Replace line 13 with private Map> accountTotals = new HashMap>();

  4. Replace lines 17–20 with int total = accountTotals.get(accountName); if (total == null) total = 0; return total;

  5. Replace lines 17–20 with Integer total = accountTotals.get(accountName); if (total == null) total = 0; return total;

  6. Replace line 24 with accountTotals.put(accountName, amount);


Correct Option: B,E,F

Given a method declared as public static List process(List nums) A programmer wants to use this method like this // INSERT DECLARATIONS HERE output = process(input); Which pairs of declarations could be placed at // INSERT DECLARATIONS HERE to allow the code to compile? (Choose all that apply.)

  1. ArrayList input = null; ArrayList output = null;

  2. ArrayList input = null; List output = null;

  3. ArrayList input = null; List output = null;

  4. List input = null; ArrayList output = null;

  5. List input = null; List output = null;

  6. List input = null; List output = null;


Correct Option: B,E,F

Given: 3. import java.util.*; 4. public class Mixup { 5. public static void main(String[] args) { 6. Object o = new Object(); 7. // insert code here 8. s.add("o"); 9. s.add(o); 10. } 11. } And these three fragments: I. Set s = new HashSet(); II. TreeSet s = new TreeSet(); III. LinkedHashSet s = new LinkedHashSet(); When fragments I, II, or III are inserted, independently, at line 7, which are true? (Choose all that apply.)

  1. Fragment I compiles

  2. Fragment II compiles

  3. Fragment III compiles

  4. Fragment I executes without exception

  5. Fragment II executes without exception

  6. Fragment III executes without exception


Correct Option: A,B,C,D,F

AI Explanation

To answer this question, let's go through each fragment and determine if it compiles and executes without exception when inserted at line 7:

Fragment I: Set s = new HashSet();

  • This fragment compiles because HashSet is a valid implementation of the Set interface.
  • It executes without exception because HashSet allows for the addition of objects using the add() method.

Fragment II: TreeSet s = new TreeSet();

  • This fragment compiles because TreeSet is a valid implementation of the Set interface.
  • It executes without exception because TreeSet allows for the addition of objects using the add() method.

Fragment III: LinkedHashSet s = new LinkedHashSet();

  • This fragment compiles because LinkedHashSet is a valid implementation of the Set interface.
  • It executes without exception because LinkedHashSet allows for the addition of objects using the add() method.

Therefore, the correct answers are: A) Fragment I compiles B) Fragment II compiles C) Fragment III compiles D) Fragment I executes without exception F) Fragment III executes without exception

class C{ int i; public static void main (String[] args) { int i; //1 private int a = 1; //2 protected int b = 1; //3 public int c = 1; //4 public System.out.println(a+b+c); //5 } }

  1. compiletime error at lines 1,2,3,4,5

  2. compiletime error at lines 2,3,4,5

  3. compiletime error at lines 2,3,4

  4. No error


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) compiletime error at lines 1,2,3,4,5 - This option is incorrect. It suggests that there are compile-time errors at all the given lines, which is not true.

Option B) compiletime error at lines 2,3,4,5 - This option is correct. There are compile-time errors at lines 2, 3, 4, and 5.

Option C) compiletime error at lines 2,3,4 - This option is incorrect. It suggests that there are compile-time errors at lines 2, 3, and 4, but not line 5.

Option D) No error - This option is incorrect. There are indeed compile-time errors in the code.

Now, let's analyze the code:

  1. The code declares a class C with a public integer variable i.
  2. Inside the main method, there is a declaration of a local integer variable i. This variable declaration shadows the class variable i. This is allowed, but it can lead to confusion. However, there is no compile-time error at this line.
  3. The code declares a private integer variable a and initializes it with the value 1. This is allowed, and there is no compile-time error at this line.
  4. The code declares a protected integer variable b and initializes it with the value 1. This is allowed, and there is no compile-time error at this line.
  5. The code declares a public integer variable c and initializes it with the value 1. This is allowed, and there is no compile-time error at this line.
  6. The code tries to print the sum of a, b, and c. However, this line is outside any method, which is not allowed in Java. This leads to a compile-time error.

The correct answer is B) compiletime error at lines 2,3,4,5. This option correctly identifies the lines with compile-time errors.

Base products are installed separately.

  1. True

  2. False


Correct Option: A

What are JSP scripting elements ?

  1. declarations

  2. scriptlets

  3. expressions

  4. All of the above


Correct Option: D

How many implicit objects in jsp?

  1. 4

  2. 7

  3. 9

  4. 8


Correct Option: C

What are the kinds of comments in JSP?

  1. Both a and b

  2. None of the above


Correct Option: C
- Hide questions