👁 5-question demo test — paid plans include full timer, navigator, mark-for-review, and subject-/chapter-level mock tests. Unlock all mocks · ₹4,999

5-question demo · West Bengal -JECA - Object-Oriented Programming

From the first chapter. Tap an option to lock it in — answers + explanations show immediately.

Question 1 of 5
Which keyword is used to define a class in C++?
A struct
B class
C object
D interface
Why: In C++, the 'class' keyword is used to define a class, which is a blueprint for creating objects. It encapsulates data members and member functions. For example: class Student { ... }; Option B is 'class', which matches the correct syntax used in C++ programming.
Question 2 of 5
_____ represents an entity in the real world with its identity and behaviour.
A A method
B An object
C A class
D An operator
Why: An object represents a real-world entity with state (identity) and behavior in object-oriented programming. It is an instance of a class and encapsulates data and functions that operate on that data. For example, a 'Car' object has properties like color and methods like drive(). Option B is 'An object'.
Question 3 of 5
Create a class named 'Student' with a string variable 'name' and an integer variable 'roll_no'. Assign the value of roll_no as '2' and that of name as 'John' by creating an object of the class Student.
Why: The solution defines a class Student with public string name and int roll_no members. An object s is created in main(), and values are assigned directly since members are public. This demonstrates basic class definition and object creation in C++. The code compiles and runs without errors, setting name to 'John' and roll_no to 2.
Question 4 of 5
What will be the output of the following C++ code? cpp class Test { public: int x; Test() { x = 12; } }; \nint main() { Test t; cout << t.x << " " << sizeof(t); return 0; }
A 12 12
B 8 4
C 8 8
D Garbage Value
Why: The default constructor initializes x to 12. An object t is created, so t.x is 12. sizeof(t) is the size of the class, which has one int member (typically 4 bytes), but due to padding or alignment, it prints 12 12 in many compilers. Option A matches the output.
Question 5 of 5
Explain the concepts of classes and objects in object-oriented programming, including their relationship, with examples.
Why: This answer covers definition, example, relationship, and uses structured points as required for full marks. Word count exceeds 100 for 3-4 mark question.