GoConqr has a new look! Let us know what you think.

Notes

Untitled

Ruma Jreij English 1 page

Untitled

Content of the notes (1)

Page 1

Note: Be careful about the difference between an empty string, and a null reference. An empty string is an object that contains no characters, and so has length 0. A null reference means there is no object present.

(Review:) what is the difference between a class and an object?

A class is a description of a possible object.

An object is a unique instance of a class.

Or you could say that a class is a plan for an object and an object is what results when the plan has been carried out.

JAVA CONSTRUCTORS

The Java interpreter starts a program by looking for a static main()method inside of the HelloTester.class file. Since the method is static the interpreter can run it without first constructing an object.

It is convenient to have a separate class that serves no other purpose than to contain the main() method. This testing class is used to start things running. Sometimes the class that contains main() is called a driver.

Usually main() constructs objects of various classes and calls their methods. These objects do the real work of the program.

The speak() method is part of an object. It exists only when there is an object to contain it (unlike a static method that does not need an object). The picture shows the action as step 3 starts.

The variable anObject refers to the object that was constructed. That object contains the speak() method. So main() can find and activate speak() with:

anObject.speak(); (SEE BELOW IMAGE)

Untitled

Information

Description
Note on Untitled, created by Ruma Jreij on 10/01/2018.
Created by
Ruma Jreij
Views
0
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?