COPA Module 11: JavaScript Introduction & Web Hosting – all 50 MCQ questions with answers
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.
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.
Which language is widely used in frontend development?
Answer: JavaScript – JavaScript runs in the browser and is the main language for front-end development.
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.
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".
What is the purpose of modulus (%) operator in javascript?
Answer: Remainder value – % gives the remainder of a division, e.g. 10 % 3 = 1.
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.
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();
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.
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".
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.
Which programming language’s syntax influences javascript syntax?
Answer: Java – JavaScript's syntax was made to look like Java (which itself follows C).
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.
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.
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.
Which JavaScript is also called as Client side Javascript?
Answer: Navigator – Netscape Navigator JavaScript was the client-side (browser) JavaScript.
Which variable works as function argument in java script?
Answer: Local variable – Function parameters are local variables – they exist only inside the function.
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.
Which part in loop evaluates the conditions?
Answer: Condition part – In for(init; condition; increment), the condition part is checked before every loop.
What is the other name of Server-side Javascript?
Answer: LiveWire Javascript – Netscape's server-side JavaScript was called LiveWire.
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.
Which type of entity is "function" and " var"?
Answer: Declaration statements – var and function are used to declare variables and functions – declaration statements.
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) { … }.
Which is a statement terminator in javascript?
Answer: ; – A semicolon (;) ends a JavaScript statement.
Which data type in javascript returns the value ‘True’ or ‘False’?
Answer: Boolean – Boolean data type has only two values: true or false.
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.
Which tag is use to terminate the current sequence in switch statement?
Answer: Break – break exits the switch case (or loop) immediately.
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.
Which one is responsible of running javascript code?
Answer: Browser – The web browser's JavaScript engine (e.g. V8 in Chrome) runs JavaScript code.
What are the three data types supported by JavaScript?
Answer: Number, String & Boolean – JavaScript's basic primitive types are Number, String and Boolean.
Which brackets is used to write array in java script?
Answer: Square bracket – Arrays are written in square brackets: var a = [1, 2, 3];
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.
What is the return type of the method parseFloat()?
Answer: Float – parseFloat("3.14") returns a floating-point (decimal) number.
Which is a type of Pop-up box in JavaScript?
Answer: Confirm Box – JavaScript has three pop-up boxes: alert, confirm and prompt.
What is Cookies?
Answer: Data stored in small text files – Cookies are small text files stored by the browser to remember user data.
Which of the following is not window object method?
Answer: unescape() – unescape() is a global function, not a method of the window object.
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.
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.
Who interprets JavaScript?
Answer: Client – JavaScript is interpreted on the client side by the user's browser.
Which variable declared outside a function in Javascript?
Answer: Global variable – A variable declared outside all functions is global and usable everywhere.
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].
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.
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.
Who developed javascript?
Answer: Brendan Eich – Brendan Eich created JavaScript at Netscape in 1995.
Which special variable holds more than one value at a time?
Answer: Array – An array stores many values in a single variable.
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.
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.
Which statement is used create custom error in javascript?
Answer: Throw – throw creates a custom error, e.g. throw "Marks too low";
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.
What is the main purpose of JavaScript?
Answer: Client side validation – JavaScript's main use is client-side validation and interactivity in the browser.