
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















































(^) Learn about objects and reference variables (^) Explore how to use predefined methods in a program (^) Become familiar with the class String (^) Learn how to use input and output dialog boxes in a program
(^) Declare a reference variable of a class type (^) Allocate memory space for data (^) Instantiate an object of that class type (^) Store the address of the object in a reference variable
Objects and Reference Variables (continued)
(^) To use a method you must know: (^) Name of the class containing method (Math) (^) Name of the package containing class (java.lang) (^) Name of the method - (pow), it has two parameters (^) Math.pow(x, y) = xy
(^) Example method call import java.lang; //imports package Math.pow(2, 3); //calls power method // in class Math (^) Dot (.) Operator: used to access the method in the class
(^) A String object is an instance of class String (^) The address of a String object with the value "Lisa Johnson" is stored in name (^) String methods are called using the dot operator
(^) A syntax to use the method printf to produce output on the standard output device is: System.out.printf(formatString); or System.out.printf(formatString, argumentList); (^) formatString is a string specifying the format of the output and argumentList is a list of arguments
(^) argumentList is a list of arguments that consists of constant values, variables, or expressions (^) If there is more than one argument in argumentList, then the arguments are separated with commas