Unit 1 - Practice Quiz

INT252

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

13 How do you define a class in ES6?

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

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

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

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

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

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

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

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

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

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

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

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

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

20 What is a Single Page Application (SPA)?

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

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

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

22 Which company maintains ReactJS?

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

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

A. npm new react-app my-app
B. npx create-react-app my-app
C. npm install create-react-app
D. node create-react 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. Vite
B. Gulp
C. Grunt
D. Babel

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

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

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

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

27 What is 'node_modules' in a React environment?

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

28 What does JSX stand for?

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

29 Can browsers understand JSX directly?

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

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

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

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

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

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

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

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

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

34 How do you embed a JavaScript expression inside JSX?

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

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 lowercase letter
B. An uppercase letter
C. An underscore
D. A dollar sign

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

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

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

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

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

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

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

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

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. <div>
B. <React.Container>
C. <Fragment> or <>
D. <Section>

43 What is the return type of a functional component?

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

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

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

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

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

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

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

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 renders 'true' or 'false' as text
B. It renders 1 or 0
C. It renders nothing
D. It throws an error

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

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

50 The 'forEach' array method returns:

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