Week2 Classes and Object
Week2 Classes and Object
Lesson Objectives:
• What is a Class
• Class Syntax
• What is an Object?
• Instantiation
• Sample Outputs
What is a Class?
What is a Class?
• It is a blueprint or template of an object that contains variables for storing
data and functions to perform operations on the data (e.g. SmartPhone
Class)
Example:
Car audi = new Car();
Instantiation Syntax
Instantiation Syntax
Instantiation Syntax
Summary:
• A class is a blueprint or a template of Java Object.
• An object is considered an object instance through instantiation which
contains state (which is known as classfield) and behavior (known as
methods.)
• Instantiation is the process of creating object.
Sources:
[1] P. Chawla, “Introduction of Object Oriented Programming”, [Online]. Available:
https://shorturl.at/msAMV. [Accessed: 16-July-2022].
[2] w3Schools, “The Java Tutorials”, [Online]. Available:
https://www.w3schools.com/java/default.asp. [Accessed: 17-July-2022].
[3] C-sharp Corner, “Introduction to Object Oriented Programming Concepts in C#”,
[Online]. Available:
https://www.csharpcorner.com/UploadFile/mkagrahari/introduction-to-object-
orientedprogramming-concepts-in-C-Sharp/. [Accessed: 17-July-2022].
Thank you!
Activity
Activity
From the given image, create your own Java Program to illustrate a Dog
class named Dog.java that will contain the given set of class field. A main
method will also be created in order to execute the program by creating an
object instance named “Bruno” with the class field values as shown in the
given image. Print the values of class fields of the Dog object created in the
Java Console window.
Activity 1:
Bruno