Learn Mode

Expressions of States and Conditions Quiz

#1

Which keyword is used to declare a constant in JavaScript?

const
Explanation

Defines a constant variable that cannot be reassigned.

#2

What is the purpose of the 'this' keyword in JavaScript?

To refer to the current class instance
Explanation

Refers to the current object.

#3

Which of the following is a valid way to comment out multiple lines in Python?

/* This is a comment */
Explanation

Invalid syntax; use '#' for single-line comments.

#4

In JavaScript, what is the purpose of the 'setTimeout' function?

To delay the execution of a function
Explanation

Executes a function after a specified delay.

#5

What is the purpose of the '===' operator in JavaScript?

Value equality without type coercion
Explanation

Checks strict equality without type conversion.

#6

What does the '==='' operator check for in JavaScript?

Value equality without type coercion
Explanation

Checks if two values are equal in value and type.

#7

In Python, what is the purpose of the 'pass' statement?

To indicate an empty block of code
Explanation

Acts as a placeholder for future code.

#8

In Python, what does the 'yield' keyword do?

Returns a value from a function and saves its state
Explanation

Pauses the function and retains its state.

#9

What is the purpose of the 'extends' keyword in Java?

To create a subclass
Explanation

Establishes inheritance between classes.

#10

What is the purpose of the 'NaN' (Not a Number) value in JavaScript?

To indicate a numerical error or undefined result
Explanation

Represents an invalid number.

#11

In Java, what is the 'final' keyword used for?

To declare a variable constant
Explanation

Prevents reassignment of variables.

#12

Which of the following is a logical operator in Python?

||
Explanation

Logical OR operator.

#13

What is the purpose of the 'finally' block in a try-catch statement in Java?

To execute code regardless of whether an exception is thrown or not
Explanation

Guarantees execution of code, irrespective of exceptions.

#14

In Python, how do you open a file in binary mode?

file = open('filename.txt', 'rb')
Explanation

Opens a file in binary mode for reading.

#15

What is the purpose of the 'try' block in a try-catch statement in Java?

To execute code regardless of whether an exception is thrown or not
Explanation

Encloses code that might throw an exception.

#16

What is the purpose of the 'super()' function in Python?

To call a method from the superclass
Explanation

Invokes a method from the parent class.

#17

In Java, what is the 'volatile' keyword used for?

To indicate that a variable may be changed by multiple threads
Explanation

Ensures visibility of changes to variables across threads.

#18

Which of the following is not a valid variable name in Python?

123variable
Explanation

Invalid due to starting with a number.

#19

What does the acronym SQL stand for?

Structured Query Language
Explanation

Language for managing relational databases.

#20

What is the purpose of the 'self' keyword in Python?

To refer to the current instance of a class
Explanation

References the instance of the class.

#21

In CSS, what does the 'box-sizing' property control?

The model used to calculate the size of an HTML element
Explanation

Defines how the size of an element is calculated.

#22

In Python, what does the '__init__' method do in a class?

It initializes the class attributes
Explanation

Called when a class is instantiated to initialize its attributes.

#23

Which CSS property is used to control the spacing between lines of text?

line-height
Explanation

Specifies the height of each line of text.

#24

In Python, what does the 'assert' statement do?

Asserts the truth of an expression
Explanation

Checks if a condition is true; raises an error if false.

#25

Which of the following is a pseudo-class selector in CSS?

:hover
Explanation

Used to define a special state of an element.

Test Your Knowledge

Craft your ideal quiz experience by specifying the number of questions and the difficulty level you desire. Dive in and test your knowledge - we have the perfect quiz waiting for you!