1. What is the primary purpose of a constructor in object-oriented programming?
A. To define methods
B. To initialize objects
C. To create variables
D. To define attributes
Answer: B
Rationale: A constructor is a special function in OOP that is used to initialize
objects when they are created.
2. What does HTML stand for?
A. HyperText Markup Language
B. Hyper Transfer Markup Language
C. Home Text Markup Language
D. Hyper Tool Markup Language
Answer: A
,Rationale: HTML stands for HyperText Markup Language, which is used to
structure content on the web.
3. In JavaScript, which of the following is used to define a function?
A. def functionName() {}
B. function functionName() {}
C. func functionName() {}
D. declare functionName() {}
Answer: B
Rationale: The function keyword is used to define a function in JavaScript.
4. Which of the following is used to insert a comment in Java?
A. /* comment */
B. # comment
C. -- comment
D. // comment
Answer: D
Rationale: // is used for single-line comments in Java.
, 5. 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.
6. What is the role of an algorithm in programming?
A. To execute the program efficiently
B. To describe the logical steps to solve a problem
C. To test the program
D. To compile the code
Answer: B
Rationale: An algorithm describes the logical steps to solve a problem, providing
the foundation for the program’s logic.
A. To define methods
B. To initialize objects
C. To create variables
D. To define attributes
Answer: B
Rationale: A constructor is a special function in OOP that is used to initialize
objects when they are created.
2. What does HTML stand for?
A. HyperText Markup Language
B. Hyper Transfer Markup Language
C. Home Text Markup Language
D. Hyper Tool Markup Language
Answer: A
,Rationale: HTML stands for HyperText Markup Language, which is used to
structure content on the web.
3. In JavaScript, which of the following is used to define a function?
A. def functionName() {}
B. function functionName() {}
C. func functionName() {}
D. declare functionName() {}
Answer: B
Rationale: The function keyword is used to define a function in JavaScript.
4. Which of the following is used to insert a comment in Java?
A. /* comment */
B. # comment
C. -- comment
D. // comment
Answer: D
Rationale: // is used for single-line comments in Java.
, 5. 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.
6. What is the role of an algorithm in programming?
A. To execute the program efficiently
B. To describe the logical steps to solve a problem
C. To test the program
D. To compile the code
Answer: B
Rationale: An algorithm describes the logical steps to solve a problem, providing
the foundation for the program’s logic.