{ "examId": "cpp-intermediate-v1", "title": "C++ Intermediate - OOP & Practical Coding", "subject": "C++", "difficulty": "intermediate", "durationMinutes": 90, "passingScore": 70, "sections": [ { "id": "theory", "title": "OOP Theory & Concepts", "questions": [ { "id": "q1", "type": "single_choice", "prompt": "In C++, what is the correct way to prevent a derived class from overriding a virtual function?", "choices": [ { "key": "A", "text": "Use the 'final' keyword" }, { "key": "B", "text": "Make it private" }, { "key": "C", "text": "Use the 'sealed' keyword" }, { "key": "D", "text": "Remove the virtual keyword" } ], "answer": "A", "allowIDK": true, "points": 10 }, { "id": "q2", "type": "multiple_choices", "prompt": "Which are true about the Rule of Five in modern C++? (Select all that apply)", "choices": [ { "key": "A", "text": "Includes copy constructor" }, { "key": "B", "text": "Includes move constructor" }, { "key": "C", "text": "Includes move assignment operator" }, { "key": "D", "text": "Includes default constructor" } ], "answer": ["A", "B", "C"], "partialCredit": true, "allowIDK": true, "points": 15 }, { "id": "q3", "type": "true_false", "prompt": "In C++, a pure virtual function must be implemented in the base class.", "answer": false, "allowIDK": true, "points": 10 } ] }, { "id": "coding", "title": "Practical Coding Tasks", "questions": [ { "id": "q4", "type": "code_simple", "prompt": "Write a function 'factorial' that computes the factorial of a non-negative integer n recursively. Return the result as an unsigned long long.", "language": "cpp", "tests": [ { "input": "0", "expected": "1", "visibility": "public" }, { "input": "1", "expected": "1", "visibility": "public" }, { "input": "5", "expected": "120", "visibility": "public" }, { "input": "10", "expected": "3628800", "visibility": "hidden" } ], "points": 20 }, { "id": "q5", "type": "code_simple", "prompt": "Implement a function 'isPalindrome' that takes a std::string and returns true if it's a palindrome (reads the same forwards and backwards), false otherwise. Ignore case and spaces.", "language": "cpp", "tests": [ { "input": "\"racecar\"", "expected": "true", "visibility": "public" }, { "input": "\"hello\"", "expected": "false", "visibility": "public" }, { "input": "\"A man a plan a canal Panama\"", "expected": "true", "visibility": "public" }, { "input": "\"Race Car\"", "expected": "true", "visibility": "hidden" } ], "points": 25 }, { "id": "q6", "type": "code_exercise", "prompt": "Create a class 'Vector2D' that represents a 2D vector with x and y components. Implement:\n- Constructor taking x and y\n- operator+ for vector addition\n- operator* for dot product (returns double)\n- magnitude() method returning the length\n- normalize() method returning a unit vector\n\nExample:\nVector2D v1(3, 4);\nVector2D v2(1, 2);\nVector2D v3 = v1 + v2; // Should be (4, 6)\ndouble dot = v1 * v2; // Should be 11\ndouble mag = v1.magnitude(); // Should be 5", "language": "cpp", "tests": [ { "input": "Vector2D(3, 4); Vector2D(1, 2); v1 + v2", "expected": "Vector2D(4, 6)", "visibility": "public" }, { "input": "Vector2D(3, 4); Vector2D(1, 2); v1 * v2", "expected": "11", "visibility": "public" }, { "input": "Vector2D(3, 4); v.magnitude()", "expected": "5", "visibility": "public" }, { "input": "Vector2D(6, 8); v.normalize().magnitude()", "expected": "1", "visibility": "hidden", "weight": 2 } ], "rubric": { "criteria": [ { "name": "Constructor implementation", "weight": 0.2 }, { "name": "operator+ overloading", "weight": 0.2 }, { "name": "operator* overloading (dot product)", "weight": 0.2 }, { "name": "magnitude() method", "weight": 0.2 }, { "name": "normalize() method", "weight": 0.2 } ], "maxPoints": 30 }, "starterCode": "class Vector2D {\nprivate:\n double x, y;\npublic:\n // Your implementation here\n};", "points": 30 } ] } ], "metadata": { "version": "1.0.0", "createdAt": "2025-10-21T17:00:00Z", "createdBy": "system", "tags": ["cpp", "c++", "intermediate", "oop", "coding", "manual-grading"], "description": "Intermediate C++ exam covering OOP concepts with three practical coding tasks: recursion, string manipulation, and class design with operator overloading.", "gradingNotes": "Theory questions (q1-q3) are auto-graded. Coding tasks (q4-q6) require manual review and grading based on rubrics and test cases." } }