1. Which of the following is a correct way to declare a variable in JavaScript?
A. let x = 10;
B. int x = 10;
C. var x => 10;
D. x = 10;
Answer: A
Rationale: let is used to declare variables in JavaScript with block-level scope.
2. Which of the following operators is used for modulus in most programming
languages?
A. %
B. /
C. *
D. //
Answer: A
Rationale: The modulus operator (%) gives the remainder of a division operation.
,3. What is the output of the following code in Java?
java
Copy
System.out.println();
A. 2.5
B. 2
C. 2.0
D. 4
Answer: B
Rationale: In Java, dividing two integers results in an integer, so = 2.
4. What is the result of the following Python code?
python
Copy
A. = [1, 2, 3]
a.append(4)
print(a)
, A. [1, 2, 3]
B. [1, 2, 3, 4]
C. 4
D. [1, 2, 4]
Answer: B
Rationale: The append() method adds the element 4 to the end of the list a.
5. What is the output of the following code in Python?
python
Copy
print(9 // 4)
A. 2
B. 2.25
C. 3
D. 4
Answer: A
Rationale: The // operator performs floor division, which returns the quotient
without the decimal part.
A. let x = 10;
B. int x = 10;
C. var x => 10;
D. x = 10;
Answer: A
Rationale: let is used to declare variables in JavaScript with block-level scope.
2. Which of the following operators is used for modulus in most programming
languages?
A. %
B. /
C. *
D. //
Answer: A
Rationale: The modulus operator (%) gives the remainder of a division operation.
,3. What is the output of the following code in Java?
java
Copy
System.out.println();
A. 2.5
B. 2
C. 2.0
D. 4
Answer: B
Rationale: In Java, dividing two integers results in an integer, so = 2.
4. What is the result of the following Python code?
python
Copy
A. = [1, 2, 3]
a.append(4)
print(a)
, A. [1, 2, 3]
B. [1, 2, 3, 4]
C. 4
D. [1, 2, 4]
Answer: B
Rationale: The append() method adds the element 4 to the end of the list a.
5. What is the output of the following code in Python?
python
Copy
print(9 // 4)
A. 2
B. 2.25
C. 3
D. 4
Answer: A
Rationale: The // operator performs floor division, which returns the quotient
without the decimal part.