0% found this document useful (0 votes)
2 views9 pages

Introduction to Programming Concepts

Questions and Answers

Uploaded by

yvonnedupreez123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

Introduction to Programming Concepts

Questions and Answers

Uploaded by

yvonnedupreez123
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introduction to Programming Memo

1. Which of the following accurately describes a programming language?


a. A language primarily used for natural communication between humans.
b. A language that translates human-readable instructions into machine-executable code.
c. A language exclusively used for mathematical computations.
d. A language developed in the late 1980s by Guido van Rossum.

2. Which programming language is known for its versatility in both front-end and back-end web
development?
a. C
b. Python
c. Java
d. JavaScript

3. Which language, developed by Google, is recognized for its simplicity and efficiency in concurrent
programming?
a. Ruby
b. Swift
c. Go
d. Rust

4. Which of the following is NOT a common element shared by all programming languages?
a. Variables
b. File Input/Output
c. Graphics Rendering
d. Conditional Statements

5. What is the purpose of parameters/arguments in programming?


a. They define the structure of a program.
b. They are used to repeat a block of code.
c. They allow for data to be passed to functions/procedures.
d. They perform comparisons between values.

6. What is the role of an Integrated Development Environment (IDE) in the programming process?
a. To convert source code into machine code
b. To facilitate collaboration between programmers
c. To provide a comprehensive set of tools for software development
d. To manage and organize files within a project

7. Which of the following best describes dynamic linking?


a. Connecting the required code to a program before it runs
b. Combining the program's object code with the necessary libraries
c. Linking the program with shared libraries at runtime
d. Identifying and correcting errors in the program's logic

8. What is the purpose of reserved words and symbols in programming languages?


a. To add decorative elements to the code
b. To denote syntax, perform operations, and represent language constructs
c. To increase the complexity of programming languages
d. To create ambiguity in the code

9. What is the primary objective of the testing phase in the software development cycle?
a. To translate design specifications into executable code
b. To identify and resolve defects in the software
c. To plan implementation strategies and develop detailed specifications
d. To assess project feasibility and define high-level requirements

1
Introduction to Programming Memo
10. Which phase of the software development cycle involves translating design specifications into executable
code?
a. Planning
b. Testing
c. Debugging
d. Coding

11. What is one of the primary purposes of using comments in source code?
a. To automatically generate documentation
b. To enforce consistent coding standards
c. To structure code visually with white space
d. To document code functionality and provide context

12. Which technique helps improve code readability by visually structuring the code and ensuring consistency
in formatting?
a. Automatic code formatting
b. Using line continuation characters
c. Inserting comments
d. Utilizing white space effectively

13. What is an object in object-oriented programming?


a. A verb that describes an action
b. A person, place, or thing
c. A mathematical equation
d. A data structure used for storing information

14. What is a property in object-oriented programming?


a. A piece of code that performs a specific task
b. An action that an object can take
c. Data or a fact about an object
d. A set of rules defining the behavior of an object

15. What do methods represent in object-oriented technology?


a. Properties of an object
b. Mathematical operations
c. Actions or behaviors of an object
d. Syntax rules of a programming language

16. What is encapsulation in object-oriented programming?


a. It refers to the process of creating objects from classes
b. It involves hiding the internal workings of an object's methods
c. It describes the process of setting properties of an object
d. It involves defining the blueprint or template for creating objects

17. What is a class in object-oriented programming?


a. A piece of code that performs a specific task
b. An action or behavior of an object
c. A blueprint or template for creating objects
d. A combination of properties and methods

18. What does instantiation mean in the context of object-oriented programming?


a. Hiding the internal details of an object's methods
b. Setting properties of an object
c. Creating an example of a class to form an object
d. Invoking methods of an object

2
Introduction to Programming Memo
19. What defines event-driven programming compared to traditional top-down programming?
a. Event-driven programming relies on a predefined sequence of steps, while traditional programming
follows user-generated events.
b. Event-driven programming involves the user selecting and ordering event procedures, while
traditional programming follows a set sequence of code execution.
c. Event-driven programming is easier to trace, while traditional programming relies on graphical user
interfaces.
d. Event-driven programming involves the operating system selecting and calling event procedures, while
traditional programming relies on manual code execution.

20. How does event-driven programming handle user interactions in graphical applications?
a. By executing a predefined sequence of code based on user input
b. By relying on the operating system to call specific event procedures based on user-generated
events
c. By creating a linear flow of code from top to bottom
d. By allowing the user to define the order of code execution

21. What is a literal in programming?


a. A function that performs calculations
b. A value used in expressions
c. A data type used for storing characters
d. An operator for connecting strings

22. Which of the following is an example of a numeric literal?


a. 'A'
b. 3.14
c. "Hello"
d. ( )

23. What does the Modulus operator (%) do?


a. Multiplies two numbers
b. Divides one number by another and returns the remainder
c. Raises one number to the power of another
d. Adds two numbers together

24. What does the `Len()` function do in Visual Basic?


a. Returns the square root of a number
b. Returns the length of a specified string
c. Compares two strings
d. Generates a random number between 0 and 1

25. Which function in Visual Basic returns the current date and time?
a. `Now()`
b. `Time()`
c. `Dateadd()`
d. `MsgBox message`

26. What does the `Strcomp()` function do?


a. Returns a sub-string out of a string
b. Converts a number to a string
c. Compares one string with another string
d. Adds a specified number of days to a date

27. What analogy is used to describe variables in computer programs?


a. Envelopes in a desk drawer
b. Books on a shelf
c. Keys in a keychain
d. Pictures in a photo album

3
Introduction to Programming Memo
28. How are variables related to memory locations in a computer?
a. Variables are stored directly in memory locations
b. Variables are like labels on memory locations
c. Variables replace memory locations
d. Variables have no relation to memory locations

29. What aspect of variables allows for flexibility in computer programs?


a. Their permanence
b. Their ability to change
c. Their capacity for encryption
d. Their static nature

30. Which of the following is NOT a valid variable name in Visual Basic?
a. myVariable
b. Last_Name
c. first-name
d. MAX_NUMBER

31. Why is it important to use descriptive variable names in programming?


a. To confuse other programmers
b. To make the code harder to read
c. To improve code readability and understandability
d. To save memory space

32. Which Visual Basic keyword is used to represent true or false values?
a. Integer
b. String
c. Boolean
d. Date

33. What is the purpose of initializing a variable?


a. To reserve memory space for the variable
b. To declare the variable's data type
c. To assign a starting value to the variable
d. To indicate the variable's name

34. Which of the following statements correctly initializes a string variable named "Password" to an empty
string in Visual Basic?
a. Password = EmptyString
b. Dim Password As String = ""
c. Password = Null
d. Dim Password As String = Null

35. What is the process called when a value is assigned to a variable and stored in memory?
a. Retrieval
b. Initialization
c. Storing
d. Declaration

36. In the statement "Age = Age + 1", what value would the variable "Age" hold after the statement is executed
if its initial value was 35?
a. 34
b. 35
c. 36
d. 37

4
Introduction to Programming Memo
37. Why is it beneficial to use constants in programming?
a. Constants take up less memory than variables.
b. Constants make the program execute faster than variables.
c. Constants allow for easy changes to values throughout the program.
d. Constants prevent errors in the program's logic.

38. What is the purpose of declaring and using constants in programming?


a. To store values that frequently change during program execution.
b. To create variables that hold values which never change during program execution.
c. To improve program readability and facilitate easy changes to values.
d. To dynamically allocate memory for program variables.

39. Which of the following statements about branching in programming is true?


a. Branching refers to the sequential execution of code from the first line to the last.
b. Branching allows the program to make decisions and execute different sections of code based
on specific conditions.
c. Branching is not supported in any programming languages.
d. Branching is only useful for printing strings in programs.

40. What is a relational operator in programming?


a. A type of loop used for iterating through lists of data.
b. An operator that assigns values to variables based on conditions.
c. An operator that performs mathematical calculations.
d. An operator used to compare values and determine relationships between them.

41. What is the purpose of the logical operator "OR" in programming?


a. It evaluates to true only if both comparisons are true.
b. It evaluates to true if at least one of the comparisons is true.
c. It reverses the truth or falseness of a condition.
d. It compares two values and determines their relationship.

42. When combining two or more comparisons using the "AND" operator, what must happen for the entire
expression to be true?
a. All comparisons must evaluate to false.
b. At least one of the comparisons must evaluate to true.
c. All comparisons must evaluate to true.
d. The comparisons must be of the same datatype.

43. Which statement accurately describes the behavior of the "If" statement in programming?
a. The "If" statement always executes the statement following it, regardless of the condition.
b. If the condition evaluates to false, the statement following the "If" statement is executed.
c. If the condition evaluates to true, the statement following the "If" statement is executed.
d. The "If" statement cannot be used to evaluate conditional expressions.

44. What happens when the condition in an "If" statement evaluates to true in Visual Basic?
a. The program skips the statement following the "If" statement.
b. The program executes only the statement following the "If" statement.
c. The program executes the statements following the "Then" keyword until it encounters "End
If".
d. The program executes the statements following the "If" statement until it reaches the end of the code
block.

45. In Visual Basic, what is the purpose of the "End If" keyword?
a. It indicates the end of the program.
b. It signifies the beginning of a conditional block.
c. It marks the end of a loop.
d. It denotes the end of a block of code associated with an "If" statement.

5
Introduction to Programming Memo
46. What is the purpose of the "Else" clause in an "If...Then...Else...End If" statement?
a. It executes the code block associated with it if the condition in the "If" statement is true.
b. It executes the code block associated with it if the condition in the "If" statement is false.
c. It signifies the end of the "If" statement.
d. It marks the beginning of the code block to be executed if the condition is true.

47. Which statement accurately describes the ElseIf clause in programming?


a. The ElseIf clause executes its associated block of code if the condition in the previous If statement is
true.
b. The ElseIf clause executes its associated block of code if the condition in the previous If statement is
false.
c. The ElseIf clause executes its associated block of code if its own condition evaluates to true,
after the previous If statement's condition evaluates to false.
d. The ElseIf clause executes its associated block of code only if all preceding conditions in the If
statement evaluate to false.

48. What is the characteristic of a Do While loop in Visual Basic?


a. The condition is evaluated at the bottom of the loop.
b. The looping continues as long as the condition is false.
c. The looping continues as long as the condition is true.
d. The loop must be processed a fixed number of times.

49. In a Do While loop, what happens if the condition is false from the beginning?
a. The loop terminates immediately.
b. The loop executes once and terminates.
c. The loop continues executing until the condition becomes true.
d. The loop executes the code inside it regardless of the condition.

50. What is the purpose of a For Next loop in Visual Basic?


a. To execute code based on a condition being true.
b. To execute code based on counting the number of times the loop is executed.
c. To execute code only once regardless of any condition.
d. To execute code repeatedly until a condition becomes true.

51. What is one of the most common reasons for using a procedure in programming?
a. To make the code run faster
b. To share code
c. To reduce the size of the code file
d. To make the code more colorful

52. In Visual Basic, what is the keyword used to define the beginning of a procedure?
a. Function
b. Method
c. Sub
d. Def

53. Which of the following statements about procedure calls in Visual Basic is true?
a. A procedure can only be called using the keyword `call`.
b. A procedure call is a single line of code that causes the code in the procedure to execute.
c. Once a procedure is called, execution does not return to the calling statement.
d. Procedures cannot be nested in Visual Basic.

54. What is the key difference between a regular procedure and an event procedure in Visual Basic?
a. Regular procedures can be called automatically, while event procedures must be called manually.
b. Event procedures are called automatically by the operating system in response to user actions,
while regular procedures must be called by the code.
c. Regular procedures do not need unique names, while event procedures do.
d. Event procedures can only be used for handling keyboard events, while regular procedures handle all
other events.

6
Introduction to Programming Memo
55. Which of the following statements is true about naming procedures in Visual Basic?
a. Procedure names can start with any character, including symbols.
b. Procedure names can be up to 500 characters long.
c. Procedure names must begin with an alphabetic character and cannot contain symbols such
as period, percent, ampersand, exclamation point, “at” symbol, or dollar sign.
d. Multiple procedures can share the same name if they perform similar tasks.

56. What is the benefit of passing information between procedures in Visual Basic?
a. It allows the program to handle different values for calculations each time the procedure is
called.
b. It reduces the amount of memory used by the program.
c. It ensures that the procedure can only be called once during the program execution.
d. It makes the procedure harder to debug and maintain.

57. What does the scope of a variable in a computer program refer to?
a. The amount of memory allocated to the variable.
b. The type of data the variable can store.
c. The set of code that can access and modify the variable.
d. The speed at which the variable can be accessed.

58. Where can a variable with local scope be accessed?


a. Only within the procedure or block of code where it is declared.
b. Within any procedure in the same module.
c. Within any procedure in the application.
d. Within the entire application, including all modules.

59. Which type of variable scope allows a variable to be accessed by all procedures within the same module?
a. Local Scope
b. Module-Level Scope
c. Global Scope
d. Block-Level Scope

60. What keyword is used to declare a global variable in Visual Basic, making it accessible to all procedures in
all modules?
a. Dim
b. Private
c. Global
d. Public

7
Introduction to Programming Memo
61. Scenario: Task: Fetch Mail
It is the year 3010. It is your birthday and one of your presents is a brand new
programmable robot assistant. It can do everything you instruct it do. You can even
teach it to do tasks comprising of a number of instructions. The first task you have
decided to teach it is to fetch mail.

The following are objects, which it knows, either by factory programming or through
pictures you programmed into its memory:

Hand
Couch
Table
Front door
Door handle
Front gate
Mailbox
Mailbox door
Mail

Your robot can automatically determine whether an object (like a door) is open or closed.
It is however up to you to test this in the tasks you give it.

To ensure that your robot is always safe and close by, you have decided to let it sit on the
couch whenever inactive. Thus you have to start every task from this position.
Remember also to always bring your robot back to this position when a task is finished.

Your robot is programmed to use its right hand as default. If you want to do something
with its left, you must specify “left hand”.

Your robot understands the following commands:


SIT DOWN / STAND UP
WALK TO [object]
PUT HAND ON [object]
TAKE HAND OFF [object]
PUSH UP/DOWN
OPEN/CLOSE [object]
MOVE INSIDE/OUTSIDE

Your robot has only one flow statement, which you can use in the commands you give it:
IF [condition] THEN
{statements}
END IF
For your robot to fetch the mail, it must pass the front door, go out at the front gate to
the mailbox, fetch the mail and put it on the table. The front door is usually left open
for fresh air in the house, but it sometimes shuts due to strong wind. For safety reasons
and to keep the dog from running into the street where it can be run over by cars, the
front gate must be closed every time a person or your robot enters or exits.

Write an algorithm for the robot to fetch the mail. Start your algorithm with “task fetch
mail” and end it with “end task”

8
Introduction to Programming Memo
Scenario: (Answer) Task: Fetch Mail
1. Stand up
2. Walk to front door
3. IF front door is closed THEN
- Put hand on door handle
- Push down door handle
- Open front door
- Take hand off door handle
4. Move outside
5. Walk to front gate
6. IF front gate is closed THEN
- Put hand on front gate
- Open front gate
- Take hand off front gate
7. Move outside
8. Close front gate
9. Walk to mailbox
10. Put hand on mailbox door
11. Open mailbox door
12. Open left hand
13. Put left hand on mail
14. Close left hand
15. Close mailbox door
16. Walk to front gate
17. IF front gate is closed THEN
- Put hand on front gate
- Open front gate
- Take hand off front gate
18. Move inside
19. Close front gate
20. Walk to front door
21. IF front door is closed THEN
- Put hand on door handle
- Push down door handle
- Open front door
- Take hand off door handle
22. Move inside
23. Walk to table
24. Put left hand on table
25. Open left hand
26. Close left hand
27. Walk to couch
28. Sit down

### End Task

You might also like