Q. What will be the output of the following JavaScript code?

Code:
System.out.println( Pattern.matches("[lfc]?", "l") ); 
  • (A) true
  • (B) false
  • (C) undefined
  • (D) l
πŸ’¬ Discuss
βœ… Correct Answer: (A) true

Q. What will be the output of the following JavaScript code?

Code:
System.out.println( Pattern.matches("\d", "9") );
  • (A) true
  • (B) false
  • (C) 9
  • (D) undefined
πŸ’¬ Discuss
βœ… Correct Answer: (A) true

Q. What will be the output of the following JavaScript code?

Code:
System.out.println( Pattern.matches("[^lfc]", "letsfind") );
  • (A) true
  • (B) false
  • (C) undefined
  • (D) l
πŸ’¬ Discuss
βœ… Correct Answer: (B) false

Q. What will be the output of the following JavaScript code?

Code:
System.out.println( Pattern.matches("[lfc]+", "f") );
  • (A) true
  • (B) false
  • (C) undefined
  • (D) 1
πŸ’¬ Discuss
βœ… Correct Answer: (A) true

Q. What among the following is an appropriate event handler for input text among the below options ?

  • (A) onclick
  • (B) onchange
  • (C) onkeyup
  • (D) onblur
πŸ’¬ Discuss
βœ… Correct Answer: (B) onchange
Explanation:

onchange is triggered when the value of an <input> (text field) changes and the user moves focus away from it.

  • It's appropriate when you want to capture the final value after the user finishes editing.

Note:

  • onkeyup (C) can also be used if you want to handle input as the user types.
  • onclick (A) and onblur (D) are less commonly used specifically for input text changes.

Q. What among the following is an appropriate when an event occurs when the user clicks on an element?

  • (A) onblur
  • (B) onkeyup
  • (C) onchange
  • (D) onclick
πŸ’¬ Discuss
βœ… Correct Answer: (D) onclick

Q. Consider the below code:
Identify the correct code in order to fetch the value entered in username text field?

Code:
< body>
< form name="register">
Enter username < input value="John" id="name" name="username">
< /form>
< /body>
  • (A) document.register.name.value
  • (B) document.getElementById ("name").value
  • (C) document.getElementByName ("name").value
  • (D) None of the above
πŸ’¬ Discuss
βœ… Correct Answer: (B) document.getElementById ("name").value

Q. Consider the below code:
Identify the correct code in order to fetch the value entered in username text field?

Code:
< body>
< form name="login">
Enter Your Name< input value="Akash" id="p_name" name="uname">
< /form>
< /body>
  • (A) document.getElementByName ("name").value
  • (B) document.login.uname.value
  • (C) document.getElementById ("p_name").value
  • (D) Both B and C
πŸ’¬ Discuss
βœ… Correct Answer: (D) Both B and C

Q. Which of the following statements is/are TRUE about DOM?

  • (A) W3C standard
  • (B) form elements can be accessed using the form object
  • (C) Each page can have multiple Document objects
  • (D) Both A and B
πŸ’¬ Discuss
βœ… Correct Answer: (D) Both A and B

Q. What is the full form DOM?

  • (A) Document Oriented Management
  • (B) Document Oriented Model
  • (C) Document Onhalt Model
  • (D) Document Object Model
πŸ’¬ Discuss
βœ… Correct Answer: (D) Document Object Model