1.
How many classes are there in a program/app?
Correct Answer
C. One or more
Explanation
In a program or app, there can be one or more classes. This means that there can be at least one class or multiple classes present in the program or app. The presence of classes allows for the organization and structuring of code, enabling the implementation of different functionalities and features. Therefore, the correct answer is "one or more."
2.
Which of the following simple types should be used for monetary values?
Correct Answer
A. Decimal
Explanation
The decimal type should be used for monetary values because it provides the highest level of precision and accuracy when dealing with decimal numbers. This is important when dealing with financial calculations to ensure that there is no loss of precision or rounding errors. The float and double types are not suitable for monetary values as they are binary floating-point types and can introduce rounding errors. The int type is also not suitable as it only represents whole numbers and cannot handle decimal values.
3.
Not all statements that performed tasks are located in method Main.
Correct Answer
A. True
Explanation
In a program, tasks can be performed by statements that are not necessarily located within the method Main. This is because a program can have multiple methods, and each method can contain statements that perform tasks. Therefore, it is possible for statements that perform tasks to be located outside of the method Main. Thus, the statement "Not all statements that performed tasks are located in method Main" is true.
4.
The int type should be used for monetary amounts.
Correct Answer
B. False
Explanation
The int type should not be used for monetary amounts because it does not support decimal places. Monetary amounts often require precision and accuracy, which can be achieved by using data types such as decimal or double.
5.
An object's property can have which of the following accessors?
Correct Answer
C. A and b
Explanation
An object's property can have both "get" and "set" accessors. The "get" accessor allows us to retrieve the value of the property, while the "set" accessor allows us to modify or update the value of the property. By using both accessors, we can control how the property is accessed and manipulated by other parts of the program.
6.
Which one refers to the data represented by an object's instance variables?
Correct Answer
B. Attributes
Explanation
Attributes refer to the data represented by an object's instance variables. Instance variables are variables that hold the state or characteristics of an object. These variables define the object's attributes and are unique to each instance of the class. Behaviors, methods, and information are not the correct terms to describe the data represented by an object's instance variables.
7.
Each object of class is identical except for the values and references it holds.
Correct Answer
A. True
Explanation
This statement is true because in object-oriented programming, a class is a blueprint for creating objects. Each object created from the same class will have the same structure and behavior defined by the class. However, the values and references held by each object can be different, allowing each object to have its own unique state. Therefore, while the objects may differ in their specific data and references, their overall structure and behavior will be identical.
8.
Methods always return a value or reference.
Correct Answer
B. False
Explanation
Methods do not always return a value or reference. In some cases, methods can be declared as void, which means they do not return anything. Void methods are used to perform a certain action without returning any value. Therefore, the statement is false.
9.
Instance variables and local variables both represent the attributes of a class.
Correct Answer
B. False
Explanation
Instance variables and local variables do not represent the same thing in a class. Instance variables are variables that are declared within a class but outside of any method, and they hold the state or data of an object. Local variables, on the other hand, are variables that are declared within a method or a block of code and are only accessible within that specific method or block. Therefore, instance variables and local variables serve different purposes and have different scopes within a class.
10.
In UML class diagrams, the + sign
Correct Answer
B. Is the public visibility symbol
Explanation
The + sign in UML class diagrams signifies the public visibility symbol. In UML, visibility symbols are used to represent the access level of class members. The + symbol specifically represents public visibility, which means that the class member can be accessed by any other class or object. This allows for the member to be used and modified by other parts of the system.
11.
Method headers contain all of the following except:
Correct Answer
B. Left brace
Explanation
Method headers in programming languages typically include the access modifier, method name, return type, and parameters. The left brace, on the other hand, is not part of the method header. It is used to denote the beginning of the method body or the block of code that defines the functionality of the method.
12.
Every #C app is composed of at least one:
Correct Answer
C. Public class declaration
Explanation
Every C# app is composed of at least one public class declaration. This is because a class is the fundamental building block of any C# application. It serves as a blueprint for creating objects and contains the code and data that define the behavior and characteristics of those objects. Without a public class declaration, there would be no structure or organization to the code, and it would be impossible to create and interact with objects in the application.
13.
C# is known as an extensible language because it declares all classes ahead of time.
Correct Answer
B. False
Explanation
C# is not known as an extensible language because it does not declare all classes ahead of time. In C#, classes can be defined and declared at any point in the code, allowing for flexibility and adaptability. This dynamic nature of C# makes it more extensible as new classes can be added or modified during runtime. Therefore, the correct answer is False.
14.
The keyword new is used to create a new method of a class.
Correct Answer
B. False
Explanation
The keyword "new" is not used to create a new method of a class. Instead, it is used to create a new instance of a class or to override an existing method in a subclass.
15.
Which of the following method headers does the following method call match?
Correct Answer
D. Action (string x, int y, double z)
Explanation
The given method call matches the method header "action (string x, int y, double z)" because the method call has a string argument followed by an int argument and then a double argument, which matches the parameter types and order of the method header.
16.
How would the following method header be represented in a UML class diagram?
Correct Answer
C. + DisplayMessage ( courseName: string)
Explanation
The method header "+ DisplayMessage ( courseName: string)" in a UML class diagram represents a public method named "DisplayMessage" that takes a parameter "courseName" of type string. The "+" symbol indicates that the method is public, and the parameter type is specified after the colon ":". This method can be called with a string argument, allowing the course name to be displayed.
17.
The comma-seperated values specified in a method called are:
Correct Answer
A. Arguments
Explanation
In programming, when a method is called, the comma-separated values that are passed to the method are called arguments. These arguments can be variables, literals, or expressions. They provide the necessary data for the method to perform its task. The method can then use these arguments to perform calculations, manipulate data, or produce a result. Therefore, the correct answer is "arguments."