CSE 240 FINAL STUDY GUIDE 2026
COMPLETE QUESTIONS AND ANSWERS.
⩥ Running the following program,
How many times the message "constructing" is printed on the screen?
#include<iostream>
using namespace std;
class Rectangle {
public:
Rectangle(){
cout <<"constructing"<<endl;
}
~Rectangle()
{cout <<"destructing"<<endl;
}
};
class Box : public Rectangle {
public:
,Box(){
cout <<"constructing"<<endl;
}
~Box()
{cout <<"destructing"<<endl;
}
};
int main(){
Box * a = new Box[5];
delete[] a;
return 0;
}. Answer- 10
⩥ Features of the logic paradigm includes
expressing computation in terms of logic predicates
using lambda calculus
classes and objects
,expressing computation in terms of boolean expressions. Answer-
expressing computation in terms of logic predicates
⩥ 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++;
}
COMPLETE QUESTIONS AND ANSWERS.
⩥ Running the following program,
How many times the message "constructing" is printed on the screen?
#include<iostream>
using namespace std;
class Rectangle {
public:
Rectangle(){
cout <<"constructing"<<endl;
}
~Rectangle()
{cout <<"destructing"<<endl;
}
};
class Box : public Rectangle {
public:
,Box(){
cout <<"constructing"<<endl;
}
~Box()
{cout <<"destructing"<<endl;
}
};
int main(){
Box * a = new Box[5];
delete[] a;
return 0;
}. Answer- 10
⩥ Features of the logic paradigm includes
expressing computation in terms of logic predicates
using lambda calculus
classes and objects
,expressing computation in terms of boolean expressions. Answer-
expressing computation in terms of logic predicates
⩥ 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++;
}