. 1 Package Pack1; 2 public class Phone { . 3 // member variable . 4 String Brand; . 5 int . Price; . 6 // member methods . 7 public void Call () { . 8 System.out.println ( "call" ); 9 } 10 public void the sendMessage () { . 11 System.out.println ( "text messaging" ); 12 } 13 }
. 1 Package Pack1; 2 . 3 // test classes . 4 public class PhoneDemo { . 5 public static void main (String [] args) { . 6 // create objects . 7 Phone P = new new Phone (); // new new heap out of the 8 9 // use member variables 10 System.out.println (p.brand); // output default value null . 11 System.out.println (p.price); // output default value 0 12 is 13 is p.brand = "millet " ; 14 = 2999 p.price ; 15 System.out.println (p.brand); // outputs "Millet" 16 System.out.println (p.price); // output 2999 . 17 18 is // member function uses . 19 P. Call (); 20 is p.sendMessage (); 21 is } 22 is }