Skip to content

Commit e47c71a

Browse files
author
Anass Rach
committed
Fix yaml syntax!
1 parent d1c8116 commit e47c71a

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

_data/quiz/questions.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -630,35 +630,35 @@
630630
explanation: "This program demonstrates a ReentrantLock bug that causes a deadlock. When the first thread calls dinnerLock.lock() at f1, it acquires the lock. Then at f2, dinnerLock.tryLock() succeeds because ReentrantLock allows the same thread to acquire the lock multiple times (reentrant behavior). So 'Eating dinner!' prints once. However, the thread acquired the lock twice (once at f1, once at f2) but only calls unlock() once. This means the lock is never fully released - it still has a hold count of 1. When the first thread exits, the lock remains held, causing the second thread to wait indefinitely at its dinnerLock.lock() call. The program hangs and never prints 'Family dinner complete' because the ExecutorService cannot shut down with a blocked thread."
631631
category: "Concurrency"
632632

633-
question: "What is the output of this family reunion code?"
634-
code: |
635-
public class FamilyReunion {
636-
public static void main(String[] args) {
637-
int grandparents = 2;
638-
int parents = 4;
639-
int children = 0;
640-
641-
for (int cousin = 0; cousin < grandparents; cousin++) {
642-
children += ++parents;
643-
System.out.print(children + " ");
644-
}
645-
646-
while (children-- > 8) {
647-
int uncles = children;
648-
children -= uncles++;
649-
System.out.print(children + " ");
650-
}
651-
652-
System.out.print("Total: " + (grandparents + parents + children));
653-
}
654-
}
655-
options:
656-
- "5 11 0 Total: 7"
657-
- "4 10 0 Total: 6"
658-
- "5 11 5 Total: 12"
659-
- "5 10 0 Total: 8"
660-
- "4 11 0 Total: 7"
661-
- None of the above
662-
correct: 1
663-
explanation: "For loop runs twice: First iteration: ++parents makes parents=5, children=0+5=5, prints '5'. Second iteration: ++parents makes parents=6, children=5+6=11, prints '11'. While loop: children-- > 8 checks 11>8 (true), then decrements children to 10. Inside loop: uncles=10, children=10-10=0, uncles++ doesn't affect children, prints '0'. Next check: 0>8 is false, loop exits. Final: grandparents=2, parents=6, children=-1 (from the failed while condition). Total: 2+6+(-1)=7."
664-
category: "Operators and Control Flow"
633+
- question: "What is the output of this family reunion code?"
634+
code: |
635+
public class FamilyReunion {
636+
public static void main(String[] args) {
637+
int grandparents = 2;
638+
int parents = 4;
639+
int children = 0;
640+
641+
for (int cousin = 0; cousin < grandparents; cousin++) {
642+
children += ++parents;
643+
System.out.print(children + " ");
644+
}
645+
646+
while (children-- > 8) {
647+
int uncles = children;
648+
children -= uncles++;
649+
System.out.print(children + " ");
650+
}
651+
652+
System.out.print("Total: " + (grandparents + parents + children));
653+
}
654+
}
655+
options:
656+
- "5 11 0 Total: 7"
657+
- "4 10 0 Total: 6"
658+
- "5 11 5 Total: 12"
659+
- "5 10 0 Total: 8"
660+
- "4 11 0 Total: 7"
661+
- None of the above
662+
correct: 0
663+
explanation: "For loop runs twice: First iteration: ++parents makes parents=5, children=0+5=5, prints '5'. Second iteration: ++parents makes parents=6, children=5+6=11, prints '11'. While loop: children-- > 8 checks 11>8 (true), then decrements children to 10. Inside loop: uncles=10, children=10-10=0, uncles++ doesn't affect children, prints '0'. Next check: 0>8 is false, loop exits. Final: grandparents=2, parents=6, children=-1 (from the failed while condition). Total: 2+6+(-1)=7."
664+
category: "Operators and Control Flow"

0 commit comments

Comments
 (0)