100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

CSE 240 Final ACTUAL Exam Questions and CORRECT Answers

Rating
-
Sold
-
Pages
28
Grade
A+
Uploaded on
20-08-2025
Written in
2025/2026

CSE 240 Final ACTUAL Exam Questions and CORRECT Answers If a function calls another function, the local variables in these two functions use the memory from - CORRECT ANSWER - different stack frames. Which C/C++ operations will acquire memory from heap? Select all that apply. - CORRECT ANSWER - - new - malloc You do not need to garbage-collect the memory, if it comes from (Select all that apply) - CORRECT ANSWER - - global memory

Show more Read less
Institution
CSE 240
Course
CSE 240










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
CSE 240
Course
CSE 240

Document information

Uploaded on
August 20, 2025
Number of pages
28
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Content preview

CSE 240 Final ACTUAL Exam Questions
and CORRECT Answers
If a function calls another function, the local variables in these two functions use the memory
from - CORRECT ANSWER - different stack frames.


Which C/C++ operations will acquire memory from heap? Select all that apply. - CORRECT
ANSWER - - new
- malloc


You do not need to garbage-collect the memory, if it comes from (Select all that apply) -
CORRECT ANSWER - - global memory
- stack memory
- static memory


What is the key difference between a static variable and a global variable? - CORRECT
ANSWER - They have different visibility.


Given the snippet of code:
int x = 5;
int bar(int j)
{
int *k = 0, m = 5;
k = &m;
return (j+m);
}
void main(void)
{
static int i =0;

,i++;
i = bar(i) + x;
}
Which variables obtain their memory from the stack? Select all that apply. - CORRECT
ANSWER - k, m, j


What is the best way of deleting an array created by "p = new StructType[size];" in C++? -
CORRECT ANSWER - delete[] p;



What memory must be garbage-collected by a destructor? - CORRECT ANSWER - heap
memory created in the constructors in the same class


What is the best way of deleting a linked list of objects in C++? - CORRECT ANSWER - Use
a loop to delete every object in the linked list.


What is the best way of deleting all the nodes in a binary tree pointed to by the root pointer? -
CORRECT ANSWER - Traverse the tree and delete each node individually.


In the implementation of the getMax() function in the PriQueue class, we need to read and write
the variables "front" and "rear", which are defined as protected members in the base class Queue.
Are the functions in the derived class allowed to access the protected members in the base class?
- CORRECT ANSWER - Yes, always.


If a class needs to inherit from multiple parent classes, the parent classes must - CORRECT
ANSWER - be inherited as virtual classes.



Defining a virtual function in class means that the function - CORRECT ANSWER - can be
redefined in its child classes.

, If you declare a pointer to the object of the parent class and use the pointer to access the object of
a child class, you can access - CORRECT ANSWER - the members that exist in the parent
class.


Assume that Publication is the root class of an inheritance tree. You want to form a linked list of
different publications in the inheritance tree, including Book, Report, Newspaper, etc. What is
the best way to create a linked list using PublListNode and Publication classes? - CORRECT
ANSWER - The PublListNode class contains the Publication class.


What type casting mechanism should be used if you want to change pointer type for pointing to a
different object in an inheritance hierarchy? - CORRECT ANSWER - dynamic_cast


It does not cause memory (storage) overhead to create multiple - CORRECT ANSWER -
names (alias) for a variable.


Given the following snippet of C++ code:
string name = "Hello";
ofstream myFile;
myFile.open(myFile);
myFile << name;myFile.close();

What does it do? - CORRECT ANSWER - It saves the word Hello into a file in the file
system.


The exception handling mechanism discussed in this course is at the level of - CORRECT
ANSWER - user program.


A throw statement is associated with a specific exception handler through the - CORRECT
ANSWER - the data type implied by the throw value.


There are various consequences to not using the C++ built-in exception handling mechanisms.
Which of them is the most serious consequence? - CORRECT ANSWER - Not restoring the
stack pointer to its original position before entering the function.

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
MGRADES Stanford University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1067
Member since
1 year
Number of followers
102
Documents
68976
Last sold
15 hours ago
MGRADES (Stanford Top Brains)

Welcome to MGRADES Exams, practices and Study materials Just think of me as the plug you will refer to your friends Me and my team will always make sure you get the best value from the exams markets. I offer the best study and exam materials for a wide range of courses and units. Make your study sessions more efficient and effective. Dive in and discover all you need to excel in your academic journey!

3.8

168 reviews

5
73
4
30
3
43
2
8
1
14

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions