COPA Module 11: JavaScript Introduction & Web Hosting – all 50 MCQ questions with answers

  1. How many different values can be returned by the error name property in javascript?

    Answer: 6 – error.name can be EvalError, RangeError, ReferenceError, SyntaxError, TypeError or URIError – 6 values.

  2. Which methods will display a window having a dialog box with a specified message, along with an OK and CANCEL button as options?

    Answer: Confirm – confirm() shows a message with OK and Cancel and returns true or false.

  3. Which language is widely used in frontend development?

    Answer: JavaScript – JavaScript runs in the browser and is the main language for front-end development.

  4. Which statement is used to test a block of code for errors?

    Answer: Try – try { } runs code that may cause an error; catch { } handles it.

  5. Which function in javassript converts a number to a string?

    Answer: toString() – num.toString() converts a number to a string, e.g. (25).toString() → "25".

  6. What is the purpose of modulus (%) operator in javascript?

    Answer: Remainder value – % gives the remainder of a division, e.g. 10 % 3 = 1.

  7. Which one enables the hosting providers to manage multiple domains on a single server?

    Answer: Web server – A web server (virtual hosting) can host many domains on one machine.

  8. Which is a valid js code to sort element of an array trade?

    Answer: Trade.sort(); – sort() is a method called on the array with brackets: trade.sort();

  9. Which web server provides good customer support if it had any issues?

    Answer: IIS – IIS is Microsoft's web server, backed by official Microsoft support.

  10. What will be the output, if the JavaScript code is executed?

    Answer: No – x is a primitive number and y is a Number object, so strict equality === is false → "No".

  11. What is the full form of DOM?

    Answer: Document Object Model – DOM = Document Object Model – the page as a tree of objects that JavaScript can change.

  12. Which programming language’s syntax influences javascript syntax?

    Answer: Java – JavaScript's syntax was made to look like Java (which itself follows C).

  13. Which method joins all array element into string with specified separator?

    Answer: Join() – join(", ") joins all array elements into one string with the given separator.

  14. Which function sends messages to the users requesting for an text input?

    Answer: Prompt() – prompt() shows a dialog box asking the user to type input.

  15. Which web server has high performance stability simple configuration and low resource usage?

    Answer: Nginx – Nginx is known for high performance, stability, simple configuration and low resource use.

  16. Which JavaScript is also called as Client side Javascript?

    Answer: Navigator – Netscape Navigator JavaScript was the client-side (browser) JavaScript.

  17. Which variable works as function argument in java script?

    Answer: Local variable – Function parameters are local variables – they exist only inside the function.

  18. Which is the open source web server solution stack package?

    Answer: XAMPP – XAMPP = X (cross-platform) + Apache + MariaDB/MySQL + PHP + Perl, free and open source.

  19. Which part in loop evaluates the conditions?

    Answer: Condition part – In for(init; condition; increment), the condition part is checked before every loop.

  20. What is the other name of Server-side Javascript?

    Answer: LiveWire Javascript – Netscape's server-side JavaScript was called LiveWire.

  21. Which was Is (a command-line interface) for JavaScript and DOM?

    Answer: JavaScript Shell – JavaScript Shell is a command-line interface to run JavaScript and test DOM code.

  22. Which type of entity is "function" and " var"?

    Answer: Declaration statements – var and function are used to declare variables and functions – declaration statements.

  23. Which is the correct syntax for the function definition?

    Answer: function function_name(parameter1, parameter2, ...) { /*Function's body*/ } – JavaScript functions have no return type: function name(p1, p2) { … }.

  24. Which is a statement terminator in javascript?

    Answer: ; – A semicolon (;) ends a JavaScript statement.

  25. Which data type in javascript returns the value ‘True’ or ‘False’?

    Answer: Boolean – Boolean data type has only two values: true or false.

  26. Which open source software is used to upload file from client to server?

    Answer: FILEZILLA – FileZilla is a free open-source FTP client to upload files from your PC to a server.

  27. Which tag is use to terminate the current sequence in switch statement?

    Answer: Break – break exits the switch case (or loop) immediately.

  28. Which of the following statements is false about hosting?

    Answer: Shared hosting is safer than dedicated hosting – Shared hosting is NOT safer – many sites share one server; dedicated hosting is safer.

  29. Which one is responsible of running javascript code?

    Answer: Browser – The web browser's JavaScript engine (e.g. V8 in Chrome) runs JavaScript code.

  30. What are the three data types supported by JavaScript?

    Answer: Number, String & Boolean – JavaScript's basic primitive types are Number, String and Boolean.

  31. Which brackets is used to write array in java script?

    Answer: Square bracket – Arrays are written in square brackets: var a = [1, 2, 3];

  32. What will be the output of the following JavaScript statement?

    Answer: 105 as an integer value – eval() runs the string as code: 10*10+5 = 105, returned as a number.

  33. What is the return type of the method parseFloat()?

    Answer: Float – parseFloat("3.14") returns a floating-point (decimal) number.

  34. Which is a type of Pop-up box in JavaScript?

    Answer: Confirm Box – JavaScript has three pop-up boxes: alert, confirm and prompt.

  35. What is Cookies?

    Answer: Data stored in small text files – Cookies are small text files stored by the browser to remember user data.

  36. Which of the following is not window object method?

    Answer: unescape() – unescape() is a global function, not a method of the window object.

  37. Which of the following softwares could be used to build a website?

    Answer: Dream Weaver – Adobe Dreamweaver is a web design tool used to build websites.

  38. Which is a free open-source HTML editor developed by Microsoft?

    Answer: Visual Studio Code – Visual Studio Code is Microsoft's free open-source code editor.

  39. Who interprets JavaScript?

    Answer: Client – JavaScript is interpreted on the client side by the user's browser.

  40. Which variable declared outside a function in Javascript?

    Answer: Global variable – A variable declared outside all functions is global and usable everywhere.

  41. Which is used to access individual value in an array?

    Answer: Element Number – Each array value is reached by its element number (index), starting from 0: a[0].

  42. Which property returns the width of the visitor’s screen in pixels?

    Answer: Screen.width() – screen.width gives the width of the visitor's screen in pixels.

  43. Which of the following is a web hosting company?

    Answer: WPX Hosting – WPX Hosting is a web hosting company; the others are tech/social companies.

  44. Who developed javascript?

    Answer: Brendan Eich – Brendan Eich created JavaScript at Netscape in 1995.

  45. Which special variable holds more than one value at a time?

    Answer: Array – An array stores many values in a single variable.

  46. Which is used in web application development, particularly for adding various dynamic functions to web pages?

    Answer: JavaScript – JavaScript adds dynamic behaviour (menus, validation, animations) to web pages.

  47. Where is JavaScript code written?

    Answer: JavaScript file and in HTML document directly – JavaScript can be written in a separate .js file or directly inside <script> in HTML.

  48. Which statement is used create custom error in javascript?

    Answer: Throw – throw creates a custom error, e.g. throw "Marks too low";

  49. Which is JavaScript's default behaviour of moving declarations to the top of their containing scope?

    Answer: Hoisting – Hoisting moves variable and function declarations to the top of their scope.

  50. What is the main purpose of JavaScript?

    Answer: Client side validation – JavaScript's main use is client-side validation and interactivity in the browser.