Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

High-Level Programming Test Questions & Answers 2022

Rating
-
Sold
-
Pages
10
Grade
A+
Uploaded on
08-04-2022
Written in
2022/2023

High-Level Programming Test Numeric Grade: 132 / 150 pts 1. Question : (TCO 2) If firstName and lastName are string object variables, which statement can be used to combine (append or concatenate) the two into a single string variable? Student Answer: fullName = firstName + lastName; fullName = firstName, lastName; fullName = firstName & lastName; fullName = firstName && lastName; Comments: Question 2 . Question : (TCO 2) What is the value of i after the following code fragment executes? int i = 2; int k = 5 ; i *= k + 1; Student Answer: 7 11 12 14 Comments: Question 3 . Question : (TCO 2) C++ selection statements include: Student Answer: for, while, do-while cout and cin if, if-else, if-else if, switch #include iostream and using namespace std; Comments: Question 4 . Question : (TCO 2) Which of the following is not a C++ logical operator? Student Answer: # && „„ ! Comments: Question 5 . Question : (TCO 2) What is the result of 5 % 7? Student Answer: 0 2 5 7 Comments: Question 6 . Question : (TCO 2) Given the following code to fill an array, int X; int data[100]; for(int i = 0; i = X; i++) data[i] = i; What should the value of X be? Student Answer: 100 101 99 i Comments: Question 7 . Question : (TCO 2) Which type of error does the following code fragment cause? const int MAX = 500; int main (void) { int foo [MAX]; for (int i = 0; i = MAX; i++) { foo [i] = i * 2; } Student Answer: Compiler, due to out-of-bounds array subscript. Run-time, due to out-of-bounds array subscript. Compiler, due to invalid array initialization. None of the above. It does not create any type of error. Comments: Question 8 . Question : (TCO 2) Given the following code fragment, what is the data type of roster[9] .name? struct student { string name; double gpa; }; student thisStudent; student roster[50]; Student Answer: string const pointer to student student double Comments: Question 9 . Question : (TCO 2) Which of the following function definitions uses pass-byvalues? Student Answer: int myFunc( int * x, int * y ); int myFunc( int x, int y ) ; int myFunc( int & x, int & y ) ; int myFunc( int @value1, int @value2 ) ; Comments: Question 10 . Question : (TCO 2) Which of the following statements calls the following function correctly? int MultiplyValues (int, int); Student Answer: int a = MultiplyValues (int x, int y); int a = MultiplyValues (10, 20); double d = MultiplyValues (int 10, int 20); All of the above Comments: Question 11.Question : (TCO 2) What is the output of the following code? void func(int x) { x = x * 2; } int main( ) { int x = 10; func(x); cout x endl; } Student Answer: 20 30 10 5 1. Question : (TCO 2) Composition is typically an example of: Student Answer: a “has a” relationship an “is a” relationship a “uses a” relationship an “is used” relationship Comments: Question 2 . Question : (TCO 2) Creating classes with private data members is an example of: Student Answer: encapsulation polymorphism inheritance abstraction Comments: Question 3 . Question : (TCO 2) Which of the following is called automatically each time an object is created? Student Answer: Compiler Builder Constructor Destructor Comments: Question 4 . Question : (TCO 2) When organizing a program into three files (main, class implementation, and class header), which is not a .cpp file? Student Answer: main none are .cpp class header class implementation Comments: Question 5 . Question : (TCO 2) Given the following class definition and lines of code, what, if anything, is wrong with Line 6 in main? class Distance { private: int feet; double inches; public: Distance( ); Distance(int initFt, double initIn); void setFeet(int feetIn); void setInches(double inchesIn); int getFeet() const; double getInches( ) const; }; int main( ) { Distance d1; //Line 1 const int MAX = 100; //Line 2 Distance list [MAX]; //Line 3 Distance d2(1, 2.3); //Line 4 Distance * pDist; //Line 5 = 5; //Line 6 // etc. – assume the remaining code is correct } Student Answer: It will not compile because feet is private and cannot be directly accessed. Distance d1; should be changed to int d1; :: = 5; should be changed to d1(feet) = 5; It will compile, but causes a run-time error because has not been declared. Comments: Question 6 . Question : (TCO 2) Given the following definitions, select the statement which is illegal. int * iptr; double * dptr; int j = 10; double d = 10.0; Student Answer: iptr = &j; dptr = &d; iptr = 0; dptr = &j; Comments: Question 7 . Question : (TCO 2) What is the output of the following code snippet? int value = 10; int * iptr = &value; *iptr = 5; Cout *iptr “ “ value; Student Answer: 5 5 10 10 5 10 10 5 Comments: Question 8 . Question : (TCO 2) What is the output of the following code snippet? int *list = new int[5]; int *ptr; for (int i = 0; i 5; i ++) list [i] = i + 1; ptr = list; delete [ ] list; cout *ptr; Student Answer: 1 address of list address of ptr error – ptr references memory which no longer belongs to the program Comments: Question 9 . Question : (TCO 2) The Graphics class in Java provides methods to: Student Answer: draw lines between any two points draw test strings starting at any point draw shapes such as rectangles, ovals, etc. All of the above Comments: Question 10 . Question : (TCO 2) In order to guarantee that only one JRadioButton is selected at any time: Student Answer: add each JRadioButton object to a different panel create a ButtonGroup object and add the JRadioBttons to it have a JCheckBox object manage the three JRadioButtons This cannot be done in Java. Comments: Question 11.Question : (TCO 2) Which of the following creates a multiline display which is user editable? Student Answer: JLabel display = new JLabel(“Enter text”); JTextField display = new JTextField(“Enter text”); JTextArea display = new JTextArea(20, 20); JScrollPane display = new JScrollPane( ); Comments: Question 12 . Question : (TCO 2) The x, y drawing coordinate system used in Java graphics Student Answer: uses character units. has the origin in the upper left corner of the display area. uses the x coordinate for the vertical axis. All of the above Comments: Question 13 . Question : (TCO 2) Which of the following Java statements creates an object of a ButtonHandler class (which implements the ItemListener interface) and associates it with a JRadioButton object called buttonOne? Student Answer: buttonOItemListener(ButtonHandler( )); buttonOItemListener(new ButtonHandler()); buttonOne.+= new ButtonHandler( ); buttonOEventHandlerr(new ButtonHandler( )); Comments: Question 14 . Question : (TCO 2) Which of the following provides the basic attributes and behaviors of a Java window – a title bar at the top of the window and buttons to minimize, maximize, and close the window? Student Answer: JLabel JFrame JSwing JWindowsControl

Show more Read less
Institution
Course

Content preview

High-Level Programming Test

Numeric Grade: pts

1. Question :
(TCO 2) If firstName and lastName are string object variables,
which statement can be used to combine (append or
concatenate) the two into a single string variable?

Student Answer: fullName = firstName + lastName;

fullName = firstName, lastName;

fullName = firstName & lastName;

fullName = firstName && lastName;


Comments:

Question 2 Question :
. (TCO 2) What is the value of i after the following code fragment
executes?
int i = 2;
int k = 5 ;
i *= k + 1;

Student Answer: 7

11

12

14


Comments:

Question 3 Question :
. (TCO 2) C++ selection statements include:

Student Answer: for, while, do-while

cout and cin

if, if-else, if-else if, switch

#include <iostream> and using namespace std;


Comments:

, Question 4 Question :
. (TCO 2) Which of the following is not a C++ logical operator?

Student Answer: #

&&

„„

!


Comments:

Question 5 Question :
. (TCO 2) What is the result of 5 % 7?

Student Answer: 0

2

5

7


Comments:

Question 6 Question :
. (TCO 2) Given the following code to fill an array,
int X;
int data[100];
for(int i = 0; i <= X; i++)
data[i] = i;
What should the value of X be?

Student Answer: 100

101

99

i


Comments:

Written for

Course

Document information

Uploaded on
April 8, 2022
Number of pages
10
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$17.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
abram23 Adams State College
Follow You need to be logged in order to follow users or courses
Sold
675
Member since
5 year
Number of followers
546
Documents
3339
Last sold
1 month ago
QUALITY WORK OF ALL KIND OF QUIZ or EXAM WITH GUARANTEE OF AN A

Im an expert on major courses especially; psychology,Nursing, Human resource Management &amp; Project writting.Assisting students with quality work is my first priority. I ensure scholarly standards in my documents . I assure a GOOD GRADE if you will use my work.

4.0

142 reviews

5
78
4
26
3
16
2
3
1
19

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

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions