Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a class to represent a student with methods to set and get the student’s name and ID.

Hard

Problem Statement

Create a class to represent a student with methods to set and get the student’s name and ID.

Sample Input

Student s; s.setName("John Doe"); s.setID(123);

Sample Output

Student Name: John Doe, ID: 123

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
#include <iostream> #include <string> class Student { private: std::string name; int id; public: void setName(std::string n); void setID(int i); void display(); }; int main() { // Logic to demonstrate Student functionality return 0; }
Log in or sign up to run or submit your code.Log inSign up
Input
Student s; s.setName("John Doe"); s.setID(123);
Expected Output
Student Name: John Doe, ID: 123