Program Design

Practice Questions

Computer Science › Program Design

Page 1 of 3
10 of 24
1

USING POINTERS

Study the following pseudocode.

**int * var1;**

**int foo = 63;**

**var1 = &foo;**

**var2 = *var1;**

What are the values of var1 and var2?

2

USING POINTERS

Study the following pseudocode.

**int * var1;**

**int foo = 63;**

**var1 = &foo;**

**var2 = *var1;**

What are the values of var1 and var2?

3

What is the value of the string kitchen after the following code is run?

  1. class home
  2. {
  3. public:
  4. home(string);
  5. void searchhome();
  6. int buyhome();
  7. private:
  8. string kitchen();
  9. };
  10. home::home(string c)
  11. {
  12. kitchen=c;
  13. }
  14. int main()
  15. {
  16. str=’big’;
  17. home(str);
  18. }
4

What is the value of the string kitchen after the following code is run?

  1. class home
  2. {
  3. public:
  4. home(string);
  5. void searchhome();
  6. int buyhome();
  7. private:
  8. string kitchen();
  9. };
  10. home::home(string c)
  11. {
  12. kitchen=c;
  13. }
  14. int main()
  15. {
  16. str=’big’;
  17. home(str);
  18. }
5

What is the difference between declaring a function as void and declaring it as int?

6

What is the difference between declaring a function as void and declaring it as int?

7

CHOOSING LOOPS

Imagine that I want to write a code for a bank that asks a user whether he/she wants to make a withdrawal, make a deposit, or quit. What type of loop would be best to use in order to make sure the user is able to do as many transactions as they want until they press quit to end the program?

8

What is not a feature of the Java programming language?

9

CHOOSING LOOPS

Imagine that I want to write a code for a bank that asks a user whether he/she wants to make a withdrawal, make a deposit, or quit. What type of loop would be best to use in order to make sure the user is able to do as many transactions as they want until they press quit to end the program?

10

What is not a feature of the Java programming language?

Page 1 of 3
Return to subject