CSE 240 FINAL EXAM HIGH-YIELD TREES,
GRAPHS, RECURSION, AND COMPLEXITY
ANALYSIS SUMMARY 2026
◉ Which of the following options is the code in C++ for
A class Student that inherits from a class Person.
A constructor in Student that calls (is able to call) a constructor in
Person
When the body of the method is not relevant to answer the question,
it has been replaced for a comment // code.
Answer: class Person {
public:
Person() {
//code
}
Person(char* lName, int year) {
// code
}
private:
char* lastName;
int yearOfBirth;
};
,class Student : public Person {
public:
Student() {
//code
}
Student(char* n, int y, char* u):Person(n, y) {
//code
}
private:
char *university;
};
◉ What is printed on screen after running this program?
Be careful, do not add extra characters, not even spaces, unless they
are part of your answer.
#include<stdio.h>
void main () {
int i = 0;
char a[] = "2020";
,while (a[i] != '\0') {
*(a + i) = *(a + i) + 1;
i++;
}
char *q = a;
q[2]='B';
printf("%s\n", a);
}.
Answer: 31B1
◉ The Java programming language is weakly typed.
Answer: FALSE
◉ What is printed on screen after running this code?
int main () {
int Employees[3][3] = {{10,20,30},{1,2,3},{15,25,35} };
cout << Employees[2][1] - Employees[1][2] ;
return 0;
}.
Answer: 22
, ◉ What is printed after running this program?
#include<iostream>
using namespace std;
class GrandPa {
public:
virtual void foo() {
cout<<"Hi, I am a GrandPa"<< endl;
}
};
class Dad : public GrandPa {
public: void foo() {
cout<<"Hi, I am a Dad"<< endl;
}
};
class Kid : public Dad {
public: void foo() {
cout<<"Hi, I am a Kid"<< endl;
}
GRAPHS, RECURSION, AND COMPLEXITY
ANALYSIS SUMMARY 2026
◉ Which of the following options is the code in C++ for
A class Student that inherits from a class Person.
A constructor in Student that calls (is able to call) a constructor in
Person
When the body of the method is not relevant to answer the question,
it has been replaced for a comment // code.
Answer: class Person {
public:
Person() {
//code
}
Person(char* lName, int year) {
// code
}
private:
char* lastName;
int yearOfBirth;
};
,class Student : public Person {
public:
Student() {
//code
}
Student(char* n, int y, char* u):Person(n, y) {
//code
}
private:
char *university;
};
◉ What is printed on screen after running this program?
Be careful, do not add extra characters, not even spaces, unless they
are part of your answer.
#include<stdio.h>
void main () {
int i = 0;
char a[] = "2020";
,while (a[i] != '\0') {
*(a + i) = *(a + i) + 1;
i++;
}
char *q = a;
q[2]='B';
printf("%s\n", a);
}.
Answer: 31B1
◉ The Java programming language is weakly typed.
Answer: FALSE
◉ What is printed on screen after running this code?
int main () {
int Employees[3][3] = {{10,20,30},{1,2,3},{15,25,35} };
cout << Employees[2][1] - Employees[1][2] ;
return 0;
}.
Answer: 22
, ◉ What is printed after running this program?
#include<iostream>
using namespace std;
class GrandPa {
public:
virtual void foo() {
cout<<"Hi, I am a GrandPa"<< endl;
}
};
class Dad : public GrandPa {
public: void foo() {
cout<<"Hi, I am a Dad"<< endl;
}
};
class Kid : public Dad {
public: void foo() {
cout<<"Hi, I am a Kid"<< endl;
}