0% found this document useful (0 votes)
2 views15 pages

REVIEW 4 Inroduction To Object Class and Java

The document discusses Object Oriented Programming (OOP), defining objects and classes, and outlining the process of creating an object. It also provides an overview of Java, including its syntax rules and a simple Java program example. Key concepts include the importance of case sensitivity in identifiers and the requirement for program file names to match class names.

Uploaded by

angelprettyn3
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views15 pages

REVIEW 4 Inroduction To Object Class and Java

The document discusses Object Oriented Programming (OOP), defining objects and classes, and outlining the process of creating an object. It also provides an overview of Java, including its syntax rules and a simple Java program example. Key concepts include the importance of case sensitivity in identifiers and the requirement for program file names to match class names.

Uploaded by

angelprettyn3
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming Paradigms

Structured Programming
Object Based Programming
Object Oriented Programming
Case
Definition
■ Object Oriented Programming (OOP is a
programming method that combines data and
instructions into a self-sufficient "object".
OBJECTS AND OBJECT CLASSES
■ Object - Objects have states and behaviors. Example: A dog has
states - color, name, breed as well as behaviors -wagging,
barking, eating.
■ An object is an instance of a class. (in relation to programming
language)
■ Software objects also have a state and behavior. A software
object's state is stored in fields and behavior is shown via
methods.
■ So in software development, methods operate on the internal
state of an object and the object-to-object communication is
done via methods.
Creating an Object:
There are three steps when creating an object from a class:
Declaration: A variable declaration with a variable name
with an object type.
Instantiation: The 'new' key word is used to create the
object.
Initialization: The 'new' keyword is followed by a call to a
constructor. This call initializes the new object.
A Class
■ Class - A class can be defined as a template/blueprint that
describes the behaviors/states that object of its type
support.
■ In software, a class is a blue print from which individual
objects are created.
Example
public class Dog
{
String breed ;
int age ;
String color ;

void barking() {
}
void hungry() {
}
void sleeping() {
}
}
Java

■ Java is a high-level programming language originally developed by Sun Microsystems


and released in 1995.
■ Java runs on a variety of platforms, such as Windows, Mac OS, and the various
versions of UNIX.
First Java Program

public class MyFirstJavaProgram


{

public static void main(String [] args)


{
[Link]("Hello World");
}
}
Basic Syntax:
■ Case Sensitivity - which means identifier Hello and hello would have different
meaning in Java.
■ Class Names - For all class names the first letter should be in Upper Case.

If several words are used to form a name of the class, each inner word's first letter
should be in Upper Case.

Example class MyFirstJavaClass


■ Method Names - All method names should start with a Lower Case letter.

If several words are used to form the name of the method, then each inner word's
first letter should be in Upper Case.

Example public void myMethodName()


Cont..
■ Program File Name - Name of the program file should exactly match the class name.

When saving the file, you should save it using the class name (Remember Java is
case sensitive) and append '.java' to the end of the name (if the file name and the
class name do not match your program will not compile).

Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should be
saved as ' [Link]
■ public static void main(String args[]) - Java program processing starts from the
main() method which is a mandatory part of every Java program..

You might also like