aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • JavaScript and Java Programming Quiz
  • What is the output of the below JavaScript? `alert(Math.s...
Multiple choice technology programming languages

What is the output of the below JavaScript?
alert(Math.sqrt(-16));

  1. -4

  2. 4

  3. Error

  4. NaN

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In mathematics, the square root of a negative number is an imaginary number. In JavaScript, Math.sqrt() on a negative number returns NaN (Not a Number).

Keep practicing — related questions

  • What is the output of the below JavaScript? alert(parseFloat("8.56"));
  • What is the output of the below JavaScript?
  • What is the output for the below lines of code? x = 0/0; alert(x);
  • What is the output of the below JavaScript?
  • What will be the output of the program? System.out.println(Math.sqrt(-4D));
  • HTML: javascript: alert(parseInt(name.value,10)); What is The Output When The User Enters 0XAB in the text ...
  • HTML: javascript: alert(parseInt(name.value,10)); What is The Output When The User Enters 08 in the text fi...
  • HTML: javascript: alert(parseInt(name.value)); What is The Output When The User Enters 08 in the text field ?
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy