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. const
B. var
C. let
D. static

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. 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 is undefined
B. It inherits 'this' from the surrounding code (lexical scoping)
C. It always refers to the global object
D. It has its own binding to 'this'

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

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

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

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

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

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

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

A. To filter the array
B. To reverse the array
C. To reduce the array to a single value
D. To loop through 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. Hoisting
D. Destructuring

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

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

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

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

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

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

13 How do you define a class in ES6?

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

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

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

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

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

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.from()
B. Array.create()
C. Array.of()
D. Array.new()

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

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

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

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

20 What is a Single Page Application (SPA)?

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

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

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

22 Which company maintains ReactJS?

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

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. npm new react-app my-app
D. npx create-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. public
B. src
C. node_modules
D. build

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

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

27 What is 'node_modules' in a React environment?

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

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, 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. class
B. styleClass
C. cssClass
D. className

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. document.render()
C. ReactDOM.mount()
D. React.render()

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

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

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. A lowercase letter
D. An underscore

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

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

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

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

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

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

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

A. index.js
B. package.json
C. index.html
D. App.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. <React.Container>
B. <Fragment> or <>
C. <div>
D. <Section>

43 What is the return type of a functional component?

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

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

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

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

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

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

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

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

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

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

50 The 'forEach' array method returns:

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