Unit 1 - Practice Quiz

INT252 50 Questions
0 Correct 0 Wrong 50 Left
0/50

1 In ES6, which keyword is used to declare a variable that cannot be reassigned?

A. static
B. var
C. let
D. const

2 What is the scope of a variable declared using the 'let' keyword?

A. Global scope
B. Function scope
C. Module scope
D. Block scope

3 Which of the following is the correct syntax for an Arrow Function in ES6?

A. const name = () => {}
B. name() => {}
C. const name -> {}
D. function name() {}

4 How does the 'this' keyword behave differently in Arrow Functions compared to regular functions?

A. It is undefined
B. It has its own binding to 'this'
C. It inherits 'this' from the surrounding code (lexical scoping)
D. It always refers to the global object

5 Which Array method creates a new array by applying a function to every element in the calling array?

A. filter
B. reduce
C. map
D. forEach

6 What does the Array.prototype.filter() method return?

A. The first element that matches the condition
B. The modified original array
C. A boolean value
D. A new array with all elements that pass the test

7 Which method checks if all elements in an array pass a specific test?

A. check()
B. filter()
C. every()
D. some()

8 What is the primary purpose of the Array.prototype.reduce() method?

A. To reduce the array to a single value
B. To reverse the array
C. To loop through the array
D. To filter the array

9 Which ES6 feature allows you to unpack values from arrays or properties from objects into distinct variables?

A. Destructuring
B. Rest Operator
C. Spread Operator
D. Hoisting

10 What is the output of the following code: const [a, b] = [1, 2]; console.log(b);?

A. [1, 2]
B. 1
C. undefined
D. 2

11 Which operator is indicated by three dots (...) and expands an iterable into individual elements?

A. Ternary Operator
B. Dot Operator
C. Spread Operator
D. Rest Operator

12 In the context of function arguments, what does the Rest operator (...) do?

A. Collects multiple arguments into a single array
B. Expands an array into arguments
C. Copies the object
D. Returns the remainder of a division

13 How do you define a class in ES6?

A. define MyClass {}
B. type MyClass {}
C. function class MyClass() {}
D. class MyClass {}

14 Which keyword is used to inherit a class from another class?

A. extends
B. super
C. implements
D. inherits

15 What is the purpose of the 'export default' syntax in ES6 Modules?

A. To delete a module
B. To export a single main value from a module
C. To import a module
D. To export multiple values

16 How do you import a named export 'data' from a module 'file.js'?

A. fetch data from './file.js'
B. import { data } from './file.js'
C. require(data) from './file.js'
D. import data from './file.js'

17 Which method creates a new Array instance from an array-like or iterable object?

A. Array.of()
B. Array.from()
C. Array.create()
D. Array.new()

18 What does the Array.prototype.find() method return?

A. The first element satisfying the condition
B. A new array
C. The index of the element
D. True or False

19 The Array.prototype.concat() method is used to:

A. Remove the last element of an array
B. Filter the array
C. Merge two or more arrays
D. Sort the array

20 What is a Single Page Application (SPA)?

A. An app that dynamically rewrites the current web page with new data from the web server
B. An application that runs offline only
C. An app that reloads the page on every click
D. A website that uses only one HTML tag

21 What is a major difference between SPA and MPA (Multi-Page Application)?

A. SPA uses HTML, MPA does not
B. SPA is slower than MPA
C. There is no difference
D. MPA reloads the page for every request, SPA does not

22 Which company maintains ReactJS?

A. Google
B. Facebook (Meta)
C. Twitter
D. Microsoft

23 What is the standard command to create a new React project using Create React App?

A. node create-react my-app
B. npm install create-react-app
C. npx create-react-app my-app
D. npm new react-app my-app

24 Which build tool is known for being faster than Webpack and is often used as an alternative to Create React App?

A. Babel
B. Vite
C. Gulp
D. Grunt

25 Which folder in a React project structure typically contains images, index.html, and the manifest file?

A. build
B. public
C. src
D. node_modules

26 In a standard React folder structure, where does the source code (components, styles) primarily reside?

A. src
B. root
C. dist
D. public

27 What is 'node_modules' in a React environment?

A. The folder for unit tests
B. The production build folder
C. The folder containing all installed npm dependencies
D. Your custom components

28 What does JSX stand for?

A. JavaScript Xhtml
B. JavaScript XML
C. Java Syntax Extension
D. JSON Xchange

29 Can browsers understand JSX directly?

A. Yes, if the file extension is .jsx
B. Yes, all modern browsers support it
C. No, it must be transpiled to regular JavaScript
D. Only Chrome supports it

30 In React, what is the equivalent of the HTML 'class' attribute in JSX?

A. styleClass
B. className
C. class
D. cssClass

31 What method is strictly used to render a React element into the DOM in older React versions (before React 18)?

A. React.render()
B. ReactDOM.render()
C. document.render()
D. ReactDOM.mount()

32 Which function is implicitly called when you write JSX tags?

A. React.compile
B. document.createElement
C. React.makeElement
D. React.createElement

33 What are the first three arguments of React.createElement()?

A. children, type, props
B. type, props, children
C. type, children, props
D. props, type, children

34 How do you embed a JavaScript expression inside JSX?

A. Inside parentheses ( )
B. Inside curly braces { }
C. Inside square brackets [ ]
D. Inside double quotes " "

35 Which of the following is a valid way to write an inline style in JSX?

A. style={ "color": "red" }
B. style={{ color: "red" }}
C. style="color: red;"
D. style={color: "red"}

36 Component names in React must start with:

A. A dollar sign
B. An uppercase letter
C. An underscore
D. A lowercase letter

37 What is the main advantage of using JSX over React.createElement?

A. It runs faster
B. It doesn't require JavaScript
C. It is standard HTML
D. It provides a visual structure that is easier to read and write

38 If you want to render a list of items in React, which array method is most commonly used?

A. forEach
B. reduce
C. map
D. filter

39 What acts as the entry point to a React application created with Vite?

A. App.js
B. index.js
C. server.js
D. main.jsx

40 Which file typically contains the root DOM node <div id="root"></div>?

A. index.html
B. package.json
C. App.js
D. index.js

41 In React, tags with no children (self-closing tags) must end with:

A. ?>
B. >
C. />
D. </>

42 What is the correct way to wrap multiple elements in JSX without adding an extra node to the DOM?

A. <Fragment> or <>
B. <div>
C. <React.Container>
D. <Section>

43 What is the return type of a functional component?

A. Boolean
B. JSX
C. HTML
D. String

44 Which environment is required to run the 'create-react-app' command?

A. Apache
B. Node.js
C. Python
D. JDK

45 What is the purpose of package.json in a React project?

A. It lists project dependencies and scripts
B. It contains the HTML templates
C. It contains the React source code
D. It stores the database configuration

46 What does the Array.prototype.reverse() method do?

A. Filters out the last element
B. Sorts the array alphabetically
C. Creates a reversed copy
D. Reverses the order of elements in place

47 How do you comment inside JSX?

A. // comment
B. <!-- comment -->
C. {/ comment /}
D. # comment

48 What happens if you try to render a Boolean value (true/false) in JSX?

A. It throws an error
B. It renders 'true' or 'false' as text
C. It renders 1 or 0
D. It renders nothing

49 Which attribute is used in JSX to handle the 'for' attribute of labels?

A. labelFor
B. htmlFor
C. forLabel
D. for

50 The 'forEach' array method returns:

A. A new array
B. undefined
C. The length of the array
D. The modified array