Ch.3 Introduction to Classes, Objects, Methods and Strings

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Name the default values of type primitive, reference, and boolean?

0, null, false

How many digits can float hold vs double?

7,15(requires twice as much memory)

What is a floating-point number

A number with a decimal point

The keywords public and private are _________ ___________.

Access modifier.

Create an Account object and assign it to variable myAccount of type Account.

Account myAccount - new Account( ); |___________| | class instance creation expression

If an instance variable is public what classes could see the data and modify it.

Any client/class can see the date and even modify it to an invalid value.

What does a classes instance maintain?

Data for each object(that is, each instance) of the class.

Using the private access modifier private is know as what?

Data/Information hiding

True or False When a return type is specified in the method header a return statement is optional.

False, the method must have a return statement with the type defined in the header.

True or False Class names are not considered an identifier?

False, they are identifiers and follow camel case naming conventions. However, the initial letter is uppercase.

True or False A constructor can return a value.

False, they cannot return values, therefore don't need return types, normally they are declared public.

What is the scope of a local variable?

Local variable may only be used in the method it was created.

What is required of each public class?

Must be stored in a file with the same class name and end with the .java file name extension.

Which access modifier tightly controls the access to and presentation of data reducing errors and increases security.

Private

What is a return type?

The type of date the method returns to its caller after performing its task.

True or False Each object(instance) of the class has its own copy of the class's instance variables belonging to particular objects of the class.

True

True or False Every instance variable has a default initial value. If true what is the default initial value for type String?

True, the default initial value for String is null because it is a reference type.

What does it mean for an instance variable to shadow?

When a local variable has the same name as an instance variable, methods body will refer to the local rather than the instance.

When should the keyword this be used?

When referring to the shadowed instance variable explicitly.

Why is Java known as an extensible language?

You can declare new classes as needed.

What is included in a method header

access modifier, return type or void, method name, parameter list. eg.) public void setName(String name) { this.name = name // instance }

The number of ____________ must match the number of ______________ in the method decelerations parameter list.

arguments, parameters.

Classes that are compiled in the same directory are considered to be in the same package-know as the ___________ ____________.

default package

By using the classes fully qualified class name Scanner input = new Scanner(System.in); could be written as what?

java.util.Scanner input = new java.util.Scanner(System.in);

A constructor must have the same ________ as the __________.

name, class

Instance variables are _______ required to be explicitly initialized before they are used in a program.

not

Declare an instance variable called name of type string.

private String name;

Create a public class named account.

public class Account { //code }


संबंधित स्टडी सेट्स

SOS HIGH SCHOOL HEALTH QUIZ 1: MENTAL, SOCIAL, AND EMOTIONAL HEALTH.

View Set

eCommerce Exam 1 Chapter 3 Pt. 1

View Set

Partnerships (GP, LLP, LP, LLC, etc)

View Set

Career Essentials in Generative AI by Microsoft and LinkedIn

View Set

Lab Safety & Scientific Method Quiz 1

View Set

Charismatic Leadership (transformational)

View Set