31 Questions
What is thepurpose of encapsulation?
To hide the internal workings of an object from the client
What is thevisibility modifier that allows the members of a class to be referenced anywhere?
Public
What is the purpose of a support method?
To assist a service method
What is the outcome of declaring a variable with public visibility?
It violates encapsulation
What is the role of an object in encapsulation?
To manage its own state
Why should instance variables not be declared with public visibility?
Because it violates encapsulation
What is the purpose of an interface in encapsulation?
To define the services an object provides
What is the purpose of a client in encapsulation?
To request the services of an object
What is the difference between public and private visibility?
Private variables are accessible within the class, while public variables are accessible outside the class
What is the purpose of a modifier in Java?
To specify the characteristics of a method or data
What is the purpose of the protected modifier in Java?
To involve inheritance
What is the primary purpose of an accessor method?
To return the current value of a variable
What is the name of the method in the Die class that generates a new face value?
roll()
What is the purpose of the toString() method in a class?
To return a character string that represents the object
What is the name of the class that represents a bank account?
Account
What is the purpose of a driver program?
To test other parts of the software
What is the name of the method that adds interest to the balance of an account?
addInterest()
What is the purpose of a mutator method?
To modify the value of a variable
What is the scope of the instance data in a class?
Private
What is the purpose of the setFaceValue() method in the Die class?
To modify the face value within a particular range
What is the name of the class that drives the use of the Account class?
Transactions
What are the primary characteristics of an object in object-oriented programming?
State and behavior
What does a class serve as in software design?
A blueprint for an object
What is represented in a UML class diagram?
The class name, attributes, and operations
What is the scope of data declared at the class level?
In all methods of the class
What is instance data?
Data specific to each object of a class
What happens when a method is called?
The flow of control jumps to the method and executes its code
What is the purpose of a constructor in a class?
To set up an object when it is initially created
What is the return type of a constructor?
No return type specified
What happens to local variables when a method finishes executing?
They are destroyed
What is the purpose of a UML class diagram?
To show the relationships among classes and objects
This quiz covers the basics of Java classes and methods, including encapsulation, graphical objects, and user interfaces.
Make Your Own Quizzes and Flashcards
Convert your notes into interactive study material.
Get started for free