Untitled

 avatar
unknown
plain_text
5 months ago
11 kB
2
Indexable
let  questions = {
    basic: {
      syntax: [
        { question: "What is the correct way to declare a variable in C++?", options: ["var x = 5;", "int x = 5;", "x = 5;", "variable x = 5;"], correct: 1, topic: "syntax" },
        { question: "How do you start an if statement in C++?", options: ["if x > 5", "if (x > 5)", "if x > 5:", "if x > 5 then"], correct: 1, topic: "syntax" },
        { question: "Which of the following is the correct way to define a function in C++?", options: ["function int myFunc() {}", "int myFunc() {}", "def myFunc():", "int myFunc(): {}"], correct: 1, topic: "syntax" },
        { question: "How do you comment a single line in C++?", options: ["// This is a comment", "# This is a comment", "/* This is a comment */", "<!-- This is a comment -->"], correct: 0, topic: "syntax" },
        { question: "What is the correct syntax for a for loop in C++?", options: ["for (int i = 0; i < 5; i++)", "for i in range(5):", "for (i = 0; i < 5)", "foreach (i in 5)"], correct: 0, topic: "syntax" }
      ],
      datatypes: [
        { question: "What is the size of int in C++ (typically)?", options: ["2 bytes", "4 bytes", "8 bytes", "Depends on the compiler"], correct: 3, topic: "datatypes" },
        { question: "Which data type is used to store decimal numbers in C++?", options: ["int", "decimal", "double", "float"], correct: 2, topic: "datatypes" },
        { question: "What is the correct way to declare a constant in C++?", options: ["const int MAX = 100;", "final int MAX = 100;", "#define MAX 100", "let MAX = 100;"], correct: 0, topic: "datatypes" },
        { question: "Which of the following is not a primitive data type in C++?", options: ["int", "char", "float", "string"], correct: 3, topic: "datatypes" },
        { question: "What is the correct way to create a string in C++?", options: ["string s = \"Hello\";", "String s = \"Hello\";", "char[] s = \"Hello\";", "str s = \"Hello\";"], correct: 0, topic: "datatypes" }
      ],
      operators: [
        { question: "What is the result of 5 / 2 in C++ (assuming int division)?", options: ["2.5", "2", "2.0", "3"], correct: 1, topic: "operators" },
        { question: "Which operator is used for string concatenation in C++?", options: ["+", "&", "||", "strcat"], correct: 0, topic: "operators" },
        { question: "What does the '&' operator do when used with variables in C++?", options: ["Bitwise AND", "Logical AND", "Returns the address of the variable", "Concatenates strings"], correct: 2, topic: "operators" },
        { question: "What is the result of 10 % 3 in C++?", options: ["3.33", "1", "0", "3"], correct: 1, topic: "operators" },
        { question: "Which operator is used to access members of a structure through a pointer?", options: [".", "->", "::", "*"], correct: 1, topic: "operators" }
      ]
    },
    intermediate: {
      functions: [
        { question: "What is function overloading in C++?", options: ["Defining multiple functions with the same name but different parameters", "Calling a function inside another function", "Using a function pointer", "Inheriting a function from a base class"], correct: 0, topic: "functions" },
        { question: "What are inline functions in C++?", options: ["Functions that are always executed first", "Functions that are expanded at the point of call", "Functions that can't have parameters", "Functions that return multiple values"], correct: 1, topic: "functions" },
        { question: "What is a default argument in C++ functions?", options: ["An argument that must be provided", "An argument with a default value if not provided in the function call", "The first argument of a function", "An argument of type void"], correct: 1, topic: "functions" },
        { question: "What is a function template in C++?", options: ["A function that can't be modified", "A function that works with any data type", "A function that doesn't return a value", "A function that's automatically inline"], correct: 1, topic: "functions" },
        { question: "What is the purpose of the 'const' keyword after a member function declaration?", options: ["It makes the function faster", "It prevents the function from modifying class members", "It makes the function static", "It allows the function to be called on const objects"], correct: 3, topic: "functions" }
      ],
      memory_management: [
        { question: "What is the purpose of the 'new' operator in C++?", options: ["To create a new variable", "To allocate memory dynamically", "To initialize a pointer", "To define a new class"], correct: 1, topic: "memory_management" },
        { question: "How do you deallocate memory allocated with 'new'?", options: ["free()", "delete", "deallocate()", "remove()"], correct: 1, topic: "memory_management" },
        { question: "What is a smart pointer in C++?", options: ["A pointer that can point to multiple objects", "A pointer that automatically manages memory deallocation", "A pointer that can't be null", "A pointer to a function"], correct: 1, topic: "memory_management" },
        { question: "What is the difference between stack and heap memory in C++?", options: ["Stack is faster, heap is slower", "Stack is for static memory allocation, heap for dynamic", "Stack is larger, heap is smaller", "There is no difference"], correct: 1, topic: "memory_management" },
        { question: "What is a memory leak in C++?", options: ["When a program uses too much memory", "When memory is allocated but never freed", "When a pointer points to an invalid memory location", "When stack overflow occurs"], correct: 1, topic: "memory_management" }
      ],
      oop_basics: [
        { question: "What is encapsulation in C++?", options: ["Hiding the implementation details of a class", "Creating multiple instances of a class", "Inheriting from a base class", "Overloading functions"], correct: 0, topic: "oop_basics" },
        { question: "What is the purpose of a constructor in C++?", options: ["To destroy an object", "To initialize an object", "To copy an object", "To compare two objects"], correct: 1, topic: "oop_basics" },
        { question: "What is inheritance in C++?", options: ["Creating multiple objects", "Defining multiple constructors", "Creating a new class from an existing class", "Overloading operators"], correct: 2, topic: "oop_basics" },
        { question: "What is polymorphism in C++?", options: ["Having multiple forms", "Creating multiple classes", "Using multiple inheritance", "Overloading constructors"], correct: 0, topic: "oop_basics" },
        { question: "What is the difference between public and private members in a C++ class?", options: ["Public members are faster", "Private members can only be accessed within the class", "Public members use less memory", "There is no difference"], correct: 1, topic: "oop_basics" }
      ]
    },
    advanced: {
      templates: [
        { question: "What is a class template in C++?", options: ["A predefined class", "A class that can't be instantiated", "A blueprint for creating generic classes", "A class without methods"], correct: 2, topic: "templates" },
        { question: "What is template specialization in C++?", options: ["Creating a specific implementation of a template for a particular data type", "Using templates in special cases", "A way to make templates faster", "A method to reduce code size"], correct: 0, topic: "templates" },
        { question: "What is a variadic template in C++?", options: ["A template with a variable name", "A template that can accept any number of arguments", "A template that only works with variables", "A template for creating variables"], correct: 1, topic: "templates" },
        { question: "What is SFINAE in C++ templates?", options: ["A type of template inheritance", "Substitution Failure Is Not An Error", "A method to specialize templates", "A way to create recursive templates"], correct: 1, topic: "templates" },
        { question: "What is a concept in C++20 with regard to templates?", options: ["A way to constrain template parameters", "A new kind of template", "A method to create abstract templates", "A type of template specialization"], correct: 0, topic: "templates" }
      ],
      stl: [
        { question: "What is the STL in C++?", options: ["Standard Template Library", "String Type Library", "System Type List", "Standard Type Locator"], correct: 0, topic: "stl" },
        { question: "Which of these is not a container in the C++ STL?", options: ["vector", "list", "map", "array"], correct: 3, topic: "stl" },
        { question: "What is an iterator in C++ STL?", options: ["A type of container", "An object that points to an element in a container", "A function that iterates over a container", "A synonym for index"], correct: 1, topic: "stl" },
        { question: "What is the difference between vector and list in C++ STL?", options: ["Vector allows random access, list doesn't", "List is faster than vector", "Vector can only store integers", "There is no difference"], correct: 0, topic: "stl" },
        { question: "What is an algorithm in the context of C++ STL?", options: ["A container class", "A function that works with containers and iterators", "A type of iterator", "A method to sort data"], correct: 1, topic: "stl" }
      ],
      advanced_features: [
        { question: "What is RAII in C++?", options: ["Random Access Iterator Implementation", "Resource Acquisition Is Initialization", "Runtime Array Index Inspection", "Recursive Algorithm Iteration Interface"], correct: 1, topic: "advanced_features" },
        { question: "What is a lambda expression in C++?", options: ["A type of loop", "An anonymous function object", "A way to declare variables", "A method to catch exceptions"], correct: 1, topic: "advanced_features" },
        { question: "What is move semantics in C++?", options: ["A way to move objects between functions", "A technique to optimize the transfer of resources", "A method to move elements in containers", "A type of inheritance"], correct: 1, topic: "advanced_features" },
        { question: "What is the purpose of the 'volatile' keyword in C++?", options: ["To make a variable changeable", "To optimize variable access", "To tell the compiler that a variable can change unexpectedly", "To create a global variable"], correct: 2, topic: "advanced_features" },
        { question: "What is the 'mutable' keyword used for in C++?", options: ["To create variables that can be modified", "To allow modification of class members in const member functions", "To make a variable thread-safe", "To create mutable containers"], correct: 1, topic: "advanced_features" }
      ]
    }
  };
Editor is loading...
Leave a Comment