Summary Absolute Java - Walter Savitch - CHAPTER 4 - DEFINING CLASSES I
60 views 0 purchase
Course
CS105 (CS)
Institution
International University Of Sarajevo
Book
Absolute Java, Global Edition
Complete coverage of CHAPTER 4 (Defining Classes I) in Absolute Java textbook by Walter Savitch. The document contains complete explanation of all content and key words with given examples. The notes are written carefully so that as you read the document you simultaneously learn all the concepts in...
Module opdracht Ontwerpen en Programmeren behaald met 7 inclusief beoordeling van de docent
All for this textbook (10)
Written for
International University Of Sarajevo
CS105 (CS)
All documents for this subject (1)
Seller
Follow
SEStudent
Content preview
22/08, 16:31
CHAPTER 4: DEFINING CLASSES I
Theory part
Object is a value of class type and is often
referred to as instance of the class. An object
differs from values of primitive types in a way that
it has both data and methods (actions).
Each object can have different data, but all
objects of a class have the same types of data
and all objects in a class have the same methods.
Each object has pieces of data that are instance
variables and the methods. Both data items and
methods are sometimes called members of the
object. The data items are also called fields.
,22/08, 16:31
Objects are named by variables of class types.
DateFirstTry date1, date2
If the variables date1 and date2 are declared as
variables of class type (They belong to the class
DateFirstTry) then in line:
date1 = new DateFirstTry ();
The variable date1 is a name of the object that is
created in the expression. To obtain an object you
must use the new operator.
The declaration of a class variable and the
creation of the object are more typically
combined into one statement:
DateFirstTry date1 = new DateFirstTry ();
Instance variables can be named by giving the
object name followed by a dot and the name of
, 22/08, 16:31
the instance variable
date1.month
date1.day
date1.year
The statement date1.month = "Hello friend" in the
main (tester) class assigns the string "Hello
friend" to the instance variable month. Instance
variables can be used just like any other variable.
The instance variable date1.month can be used
just like any other variable of type String.
Practise part
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through EFT, credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying this summary from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller SEStudent. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy this summary for R65,77. You're not tied to anything after your purchase.