Java Module 6 Flashcards
9 Questions
100 Views

Java Module 6 Flashcards

Created by
@GladLepidolite6058

Questions and Answers

Which statement is true about objects? Select the one correct answer.

  • An object is a blueprint for creating concrete realization of abstractions.
  • An object is an instance of a class. (correct)
  • An object is a variable.
  • An object is a reference.
  • How do objects communicate in Java? Select the one correct answer.

  • They communicate by calling static methods of each other's classes.
  • They communicate by modifying the static variables of each other's classes.
  • They communicate by modifying each other's fields.
  • They communicate by calling each other's instance methods. (correct)
  • Which statement is true about methods? Select the one correct answer.

  • A method is a category of objects.
  • A method is an operation defining the behavior for a particular abstraction. (correct)
  • A method is an implementation of an abstraction.
  • A method is a blueprint for making operations.
  • Given the following code, which statements express the most accurate association? (choose 3)

    <p>A Train object has a TrainDriver object.</p> Signup and view all the answers

    Which statement is true about instance members? Select the one correct answer.

    <p>An instance member belongs to an instance, not to the class as a whole.</p> Signup and view all the answers

    Which statement is true about Java? Select the one correct answer.

    <p>None of the above.</p> Signup and view all the answers

    Which command from the JDK should be used to execute the main() method of a class named SmallProg? Select the one correct answer.

    <p>java SmallProg</p> Signup and view all the answers

    Given that Thing is a class, how many objects and how many references are created by the following code? Thing item, stuff; item = new Thing(); Thing entity = new Thing(); Select the two correct answers.

    <p>Two references are created.</p> Signup and view all the answers

    Given the following code, which statements are true? Select the two correct answers.

    <p>Objects of class A have a field named value2.</p> Signup and view all the answers

    Study Notes

    Objects and Classes

    • An object is an instance of a class.
    • Objects can only communicate by calling each other's instance methods.

    Constructors

    • The first line of a constructor declaration is essential to initializing an object. In code, it is indicated as (2).

    Methods

    • A method defines the behavior of an abstraction, serving as an operation rather than a mere blueprint or attribute.

    Composition in Classes

    • A Train object consists of an array of Carriage objects and has a TrainDriver object.
    • Relationships in code can illustrate ownership, indicating that a larger class can hold smaller components.

    Instance Members

    • Instance members, such as fields, belong to specific instances and are distinct from static members tied to the class itself.

    Java Program Execution

    • Java programs can create objects, but destruction is managed by the garbage collector.
    • Compatibility of the Java Virtual Machine (JVM) with the Java Platform is crucial for execution.

    JDK Commands

    • To execute the main method of a class named SmallProg, use the command: java SmallProg.

    Object and Reference Creation

    • In the provided code, three references are created and two objects are instantiated.

    Inheritance

    • Inheritance illustrates that Class B is a subclass of Class A, having access to its fields while also introducing its own attributes.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge with these flashcards on Java Module 6. This quiz covers key concepts related to objects and constructors in Java, helping you solidify your understanding of programming fundamentals. Perfect for students looking to review essential topics.

    More Quizzes Like This

    Java Programming Basics
    18 questions

    Java Programming Basics

    CleanlyBrazilNutTree avatar
    CleanlyBrazilNutTree
    Use Quizgecko on...
    Browser
    Browser