Minggu, 17 Maret 2013

Posted by Kiki Risky | File under : ,
 Creating objects of a Class

To create a new operator takes an object. The shape is generally as follows:

namaKelas namaKelas namaObjek = new ();


example:

ObjMahasiswa student = new Student ();


 Accessing Data and Methods of a Class

 To access the data and the method on an object can be done in the following way:

namaObjek.namaVariabel;
namaObjek.namaMethod ();

That needs to access the data and methods is how to set the level of accessibility (accesibility level) the two elements of the class that access, whether the default, public, private, or protected.

example:

objMahasiswa.NIM;
objMahasiswa.bayarKuliah ();

0 komentar:

Posting Komentar