-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestionBank.java
More file actions
58 lines (46 loc) · 1.82 KB
/
Copy pathQuestionBank.java
File metadata and controls
58 lines (46 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.ArrayList;
import java.util.List;
/**
* PART D: Question Sourcing Integration
* A pre-populated storage of predefined question objects.
* Used by BankQuestionSource to fetch questions pseudo-randomly.
*/
public class QuestionBank {
private static final List<Question> bank = new ArrayList<>();
static {
// Pre-populate the bank with a variety of questions
bank.add(new MCQQuestion(
"Which keyword is used to inherit a class in Java?",
2, "Easy", "B"));
bank.add(new MCQQuestion(
"What is the time complexity of binary search?",
2, "Medium", "C"));
bank.add(new MCQQuestion(
"Which data structure uses LIFO ordering?",
2, "Easy", "A"));
bank.add(new TrueFalseQuestion(
"Java supports multiple inheritance through classes.",
1, "Easy", false));
bank.add(new TrueFalseQuestion(
"An interface can have default methods in Java 8+.",
1, "Medium", true));
bank.add(new EssayQuestion(
"Explain the SOLID principles of object-oriented design.",
10, "Hard", 150));
bank.add(new EssayQuestion(
"Describe the differences between SQL and NoSQL databases.",
10, "Hard", 200));
bank.add(new ProgrammingQuestion(
"Write a Java method to reverse a linked list in place.",
20, "Hard", "Java", "next"));
bank.add(new ProgrammingQuestion(
"Implement a binary search algorithm in Java.",
15, "Medium", "Java", "mid"));
}
/**
* Returns the internal question list for random access.
*/
public static List<Question> getAll() {
return bank;
}
}