4.10 Creating Objects


4.10 Creating Objects

After declaring object references, the corresponding objects can be created. The KJP statement to create objects has the following structure:

       create  object_ref_name  of class  class_name  

For example, assume that the program described previously is to create an object for each of the two class definitions, Employee and Ball. The declarations of the object reference called emp_obj of class Employee, and the object reference ball1 of class Ball were previously provided. The KJP statements for creating the two objects are:

       create emp_obj of class Employee       create ball1 of class Ball 




Object-Oriented Programming(c) From Problem Solving to Java
Object-Oriented Programming (From Problem Solving to JAVA) (Charles River Media Programming)
ISBN: 1584502878
EAN: 2147483647
Year: 2005
Pages: 184

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net