This 'ch8 java' quiz assesses key concepts in Java class design, including public interfaces, method functionalities, and access modifiers. It evaluates understanding of static methods, private variables, and the use of 'this' reference, essential for anyone learning Java programming.
Methods and instance variables can both be either public or private.
Information hiding is achieved by restricting access to class members via keyword public.
The private members of a class are directly accessible to the client of a class.
None of the above is true.
Rate this question:
A compilation error occurs.
A runtime error occurs.
A logic error occurs.
Nothing happens. The program compiles and runs.
Rate this question:
Public methods
Hiding implementation details from clients of a class
Accessing static class members
The process of releasing an object for garbage collection
Rate this question:
Static import java.lang.Math.*.
Import static java.lang.Math.*.
static import java.lang.Math
Import static java.lang.Math
Rate this question:
Cause syntax errors if used as a left-hand value.
Be initialized
Be modified
None
Rate this question:
Methods.
Constructors
Variables (or fields).
All of the above.
Rate this question:
Is-a relationship.
Has-a relationship.
Many-in-one relationship.
One-to-many relationship
Rate this question:
Final, static.
Static, static.
Static, final.
Final, final
Rate this question:
Initialize instance variables.
When overloaded, can have identical argument lists.
When overloaded, are selected by number, types and order of types of parameters.
A and c.
Rate this question:
Be overloaded.
Initialize variables to their defaults.
Specify return types or return values.
Have the same name as the class.
Rate this question:
Public
Private
Protected
All of the above
Rate this question:
Zero-argument constructor.
No-argument constructor.
Default constructor
Main constructor.
Rate this question:
Query, mutator.
Accessor, mutator.
Mutator, accessor.
Query, accessor.
Rate this question:
It will be used only by other classes in the same package
It will be used by classes that are not in the same package
It is in the same directory as the other classes in the package.
It has a unique name
Rate this question:
Causes a compilation error
Imports all classes in the library.
Imports the default classes in the library
Imports the classes in package java.lang
Rate this question:
The compiler always creates a default constructor for a class.
If a class’s constructors all require arguments and a program attempts to call a no-argument constructor to initialize an object of the class, a compilation error occurs.
A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public no-argument constructor
None.
Rate this question:
Crafting new classes and reusing existing classes.
Understanding class library implementations
Carefully testing classes they design
Carefully documenting classes they design
Rate this question:
Printf
Format
FormatString
ToFormatString
Rate this question:
A directory structure used to organize classes and interfaces.
A mechanism for software reuse
A group of related classes and interfaces
All
Rate this question:
Values
GetValues
Constants
GetConstants
Rate this question:
Colon (:), semicolon (;).
Semicolon (;), colon (:).
Comma (,), semicolon (;).
Semicolon (;), comma (,).
Rate this question:
The instance variables are public.
The instance variables are private
The methods perform validity checking
Both b and c.
Rate this question:
A method to refer explicitly to the instance variables and other methods of the object on which the method was called.
A method to refer implicitly to the instance variables and other methods of the object on which the method was called.
An object to reference itself.
All of the above.
Rate this question:
Are final.
Are public
Are private
Are shared by all objects of a class
Rate this question:
Elevate the importance of data
Are only approximations or models of real-world concepts and behaviors
Capture two notions, data representation and operations
All of the above.
Rate this question:
Is public
Is private
Has package access
Is static
Rate this question:
Public constructors.
public instance variables.
public methods
All of the above.
Rate this question:
The actual data representation used within the class is of no concern to the class’s clients
Clients generally care about what the class does but not how the class does it
Clients are usually involved in a class’s implementation
Hiding the implementation reduces the possibility that clients will become dependent on class-implementation details
Rate this question:
Private
Public
Protected
Static
Rate this question:
The statement declares a package that exists at deitel.com
The statement uses the Sun Microsystems convention of package naming
The statement should be placed inside the class declaration
The statement will generate a compile time error
Rate this question:
-p.
-a.
-d.
-dir.
Rate this question:
An enum declaration is a comma-separated list of enum constants and may optionally include other components of traditional classes, such as constructors, fields and methods
Any attempt to create an object of an enum type with operator new results in a compilation error.
An enum constructor cannot be overloaded
An enum constructor can specify any number of parameters
Rate this question:
Method finalize does not take parameters and has return type void.
Memory leaks using Java are rare because of automatic garbage collection
Objects are marked for garbage collection by method finalize.
The garbage collector reclaims unused memory
Rate this question:
A static method must be used to access private static instance variables
A static method has no this reference
A static method can be accessed even when no objects of its class have been instantiated
A static method can call instance methods directly
Rate this question:
Accessing a private variable
Accessing a public variable
Accessing a local variable.
Accessing a field that is shadowed by a local variable
Rate this question:
Single-type-import declaration.
All-type-import declaration
Multiple-import declaration
Type-import-on-demand declaration
Rate this question:
Root directory of the package, -d.
Current directory, -d.
Root directory of the package, -classpath
Current directory, -classpath.
Rate this question:
Quiz Review Timeline (Updated): Mar 21, 2023 +
Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.
Wait!
Here's an interesting quiz for you.