Intro To Class, Objects And Methods

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Dipishar
D
Dipishar
Community Contributor
Quizzes Created: 1 | Total Attempts: 393
Questions: 17 | Attempts: 393

SettingsSettingsSettings
Class Quizzes & Trivia

.


Questions and Answers
  • 1. 

    How many classes are there in a program/app? 

    • A.

      2

    • B.

      2 or more

    • C.

      One or more

    • D.

      0 or 1

    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."

    Rate this question:

  • 2. 

    Which of the following simple types should be used for monetary values?

    • A.

      Decimal

    • B.

      Float

    • C.

      Int

    • D.

      Double

    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.

    Rate this question:

  • 3. 

    Not all statements that performed tasks are located in method Main. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 4. 

    The int type should be used for monetary amounts. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 5. 

    An object's property can have which of the following accessors?

    • A.

      Get

    • B.

      Set

    • C.

      A and b

    • D.

      None

    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.

    Rate this question:

  • 6. 

    Which one refers to the data represented by an object's instance variables? 

    • A.

      Behaviours

    • B.

      Attributes

    • C.

      Methods

    • D.

      Information

    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.

    Rate this question:

  • 7. 

    Each object of class is identical except for the values and references it holds. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 8. 

    Methods always return a value or reference. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 9. 

    Instance variables and local variables both represent the attributes of a class. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 10. 

    In UML class diagrams, the + sign 

    • A.

      Signifies that the section can be expanded

    • B.

      Is the public visibility symbol

    • C.

      Stands for addition

    • D.

      None of the above

    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.

    Rate this question:

  • 11. 

    Method headers contain all of the following except: 

    • A.

      Access modifer

    • B.

      Left brace

    • C.

      Method name

    • D.

      Return type

    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.

    Rate this question:

  • 12. 

    Every #C app is composed of at least one: 

    • A.

      Public method

    • B.

      Data member

    • C.

      Public class declaration

    • D.

      Imported class

    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.

    Rate this question:

  • 13. 

    C# is known as an extensible language because it declares all classes ahead of time.

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 14. 

    The keyword new is used to create a new method of a class. 

    • A.

      True

    • B.

      False

    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.

    Rate this question:

  • 15. 

    Which of the following method headers does the following method call match?

    • A.

      Action ()

    • B.

      Action (int x, double y, string z)

    • C.

      Action (string x, double y, int z)

    • D.

      Action (string x, int y, double z)

    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.

    Rate this question:

  • 16. 

    How would the following method header be represented in a UML class diagram?

    • A.

      + DisplayMessage ()

    • B.

      + DisplayMessage ( string )

    • C.

      + DisplayMessage ( courseName: string)

    • D.

      + DisplayMessage ( courseName )

    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.

    Rate this question:

  • 17. 

    The comma-seperated values specified in a method called are:

    • A.

      Arguments

    • B.

      References

    • C.

      Objects

    • D.

      Parameters

    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."

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 17, 2015
    Quiz Created by
    Dipishar

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.