• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/27

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

27 Cards in this Set

  • Front
  • Back

The name of a class is to start with an upper case letter. Is this must or convention?

convention

The name of constructor (must be the same name as the class name) or (can be any name, just like other methods.)

must be the same name as the class name

What is a constructor's return type?

A constructor does not have a return type

It is legal to have more than one constructor in a given class.

True

In a class, if a field is private, it can be accessed directly from (any class) or (only inside its class).

only inside its class

The general recommendation for access modifiers in a typical class is that instance variables are (public, private) and methods are (public, private).

private

public

In a class, fields can _____ types, _____ types, and _____ types.

basic data types


existing Java types


user-defined types (from user-defined classes)

Accessors and mutuators are used to access and modify _____ of a class from (inside, outside) the class

field variables


outside

_____ methods typically take no parameter.

Accessor

_____ methods typically take one parameter, of the same type as the corresponding field.

Mutator

_____ methods typically return the same type as the corresponding field.

Accessor

_____ methods typically are void methods.

Mutator

When coding method that performs calculations on fields of that class, these fields (must, don't need to) be passed as parameters to the method.

Don't need to


(Because the class methods have direct access to them.)

What is the keyword used for declaring a constant?

final

What is the keyword used for declaring a class variable or method?

static

About enum...


It's part of the package _____.


It can be used for _____, and _____.


This object is a ____ object,

java.lang


self-documentation, and improving the readability of your code


constant

public Color getColor()


This is (accessor, mutator, constructor) because _____.

accessor


Because it's public.

public void setColor (Color c)


This is (accessor, mutator, constructor) because _____.

mutator


Because in addition to public, client will be able to change (client set color)

public static double foo1 (String s)


What is the return type of method foo1?

double

public String foo2 (char c)


What is the return type of method foo2?

String

public static double foo1 (String s)


Is method foo1 a class or instance method? Explain.

Aa class method


Because of keyword "static" is used.

public String foo2 (char c)


Is method foo2 a class or instance method? Explain.

An instance method

Because of keyword "static" is not used,

"Airplane" class...


public static double foo1 (String s)




Write a line or two of code to call method foo1 from a client class.

double d = Airplane.foo1( "Boeing" );


(Airplane.foo1が合っていればOK)

"Airplane" class...


public String foo2 (char c)




Write a line or two of code to call method foo2 from a client class. assume we have instantiated an object named a1.

String s = a1.foo2( 'A' );

Inside method main...

Airplane.foo3 (34.6);




Reconstruct the header of method foo3 (which belongs to the class Airplane)

public static void foo3( double d );

Inside method main...


Airplane a = new Airplane();


int n = a.foo4("Hello");




Reconstruct the header of method foo4 (which belongs to the class Airplane)

public int foo4( String s );

enum Seasons (Winter, Spring, Summer, Fall);


System.out.println( Seasons.Spring.ordinal() );




What is the output?

1