Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java MCQ Quiz — Sanfoundry question bank

A self-contained quiz app over 1,789 Java multiple-choice questions scraped from Sanfoundry, with Sanfoundry's own answers and explanations.

Run it

Double-click index.html. That's it — no server, no build, no internet needed. The question bank is embedded in questions.js, so it works straight off the filesystem.

Files

File Purpose
index.html Page structure (start / quiz / results screens)
styles.css All styling, light + dark themes
app.js Quiz engine — filtering, scoring, review, CSV export
questions.js The question bank (window.QUIZ_DATA), 1.2 MB
questions.json Same data as plain JSON, if you want to reuse it elsewhere
theory.js Theory Q&A data (window.THEORY_DATA) for the Theory tab
rules.html Study sheet — the recurring code-question rules in plain English, each followed by a real question from the bank. Open it separately.

Keep all five in the same folder.

What's in the bank

Category Questions Topics
Core Java 1,164 117
OOP using Java 344 26
Interview & Aptitude 141 11
Advanced Java 140 14
Total 1,789 165
  • 847 are code questions — 840 carry a Java code block in the question and 110 have code inside the options (e.g. "which output is correct?"). The other 942 are plain theory. Note OOP using Java is 100% code-output questions, so it disappears under the Theory only filter.
  • 1,502 carry Sanfoundry's explanation; 581 also include the compiler/run output.
  • Every question links back to its source page on sanfoundry.com.

Features

  • Scroll-based practice. Questions are laid out in a continuous page — scroll down and answer each one in place. You only click Next page once you reach the bottom.
  • Questions per page: 10 / 20 / 30 / 50 (default 30).
  • Category filter: clicking a single category (e.g. Interview & Aptitude) practises that category on its own; click others to add them back, or Select all to reset.
  • Question-type filter: All (1,789) / Code output only (847) / Theory only (942). A question counts as code if a snippet appears in the question or in the options — explanation/output code doesn't count. Every category and topic count on the page re-tallies live to match, and topics with none of the chosen type are hidden.
  • Topic filter: any of the 165 topics, searchable, scoped to the chosen categories.
  • Length: 10 / 25 / 50 / 100 / 200 / all 1,789.
  • Practice mode — the answer and explanation reveal instantly, in place, as you go. Exam mode — selections are recorded silently, scored at the end.
  • Optional question shuffle, option shuffle, and timer.
  • A sticky bar tracks answered / total and progress as you scroll.
  • Results: score ring, per-topic breakdown, full review (filterable to wrong only), retry wrong answers only, and CSV export.
  • Light/dark theme, remembered between sessions. Responsive down to phone width.

Theory tab

A second tab in the top bar, separate from the MCQ quiz. 229 written-answer questions from two sources, filterable by source and by topic.

COS 202 — your course companion (131)

Extracted from cos202_theory.pdf, in three parts:

Part Count What it is
Rapid-fire 65 Short Q&A across 9 subsections, with answers
Likely exam prompts 46 The "Likely theory question" wordings flagged through the PDF — no model answer, shown as prompts to rehearse
Model questions 20 Section 22's full model answers

Sanfoundry tutorial FAQs (98)

Scraped from the "FAQs on …" section at the end of each Java tutorial article — genuine open-answer questions, not MCQ. Plus 99 "key points to remember" bullets from the same articles (shown when Sanfoundry is in view). Every card links to its source article.

Coverage: Java Basics (43), Inheritance (8), Interfaces (8), Exceptions (7), Methods (6), Constructors (6), Keywords (6), Polymorphism (5), Abstraction (5), Encapsulation (4).

Answers are hidden behind a Show answer button (flashcard style), with Reveal all / Hide all.

Predicted code questions — NOT from Sanfoundry

The last block on the Theory tab holds 10 code questions written as extra practice, clearly marked as such. They are predictions in the style of the syllabus, not published Sanfoundry material. Every answer was verified by compiling and running the code on JDK 21 — the stated outputs are the real program outputs, not a judgement call. They cover: field-vs-method dispatch, static hiding, constructor chain order, private-not-inherited, missing no-arg constructor, byte overflow, int vs double division, == vs equals, overload resolution, and static vs instance.

Data format

window.QUIZ_DATA = {
  meta: { generated, source, count, topics: [...], categories: [...] },
  questions: [
    {
      id:    1,
      cat:   "Core Java",
      topic: "Inheritance",
      q:     "Which of this keyword must be used to inherit a class?",
      code:  ["class A { ... }"],          // optional: question code blocks
      opts:  [ { k: "a", t: "super" },
               { k: "b", t: "", c: ["..."] } ],   // c = option-level code
      ans:   "d",                          // Sanfoundry's answer letter
      exp:   "Explanation text",            // optional
      expCode: ["$ javac A.java\n..."],     // optional: output block
      src:   "https://www.sanfoundry.com/java-mcqs-inheritance/"
    }
  ]
};

Where the data came from

Sanfoundry sits behind Cloudflare, which blocks scripted requests. The pages were retrieved from the Internet Archive's snapshots of sanfoundry.com instead (190 topic pages), then parsed: questions segmented on Sanfoundry's "View Answer" blocks, GeSHi-highlighted <pre> markup converted back to plain source, ads and promo text stripped, and 146 cross-listed duplicates removed.

All answers are Sanfoundry's own — none were inferred or corrected. A handful of Sanfoundry's answers are debatable; they are reproduced as published.

Note that Sanfoundry publishes many questions on more than one page with the options in a different order (so the correct letter differs between copies, while the correct text is the same). Duplicates that were identical in both text and options were removed; those that differ only in option order were kept, since they are genuinely separate pages.

Content belongs to Sanfoundry. This is for personal study use.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages