0% found this document useful (0 votes)
6 views16 pages

Introduction To OOP

Uploaded by

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

Introduction To OOP

Uploaded by

mainul684islam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Introduction to OOP

using Java

CSE 1115: Object Oriented Programming

1
What is Programming

 Instruction to computer/device to perform task.


 Computer understands only 0 and 1. Nothing

else.
 So, we need to send the instruction in the form of

0, 1
⚫ Do you write program with just 0 and 1?
Evolution of Programming
 Machine level programming
⚫ Send instruction in binary format
 Assembly Programming
⚫ send code instead of binary code.
⚫ Need assembler to convert to binary
 High level programming
⚫ Code is close to English Language
⚫ Need Compiler to convert to binary
⚫ 3 types
 Non structured
 Structured/Procedural

 Object Oriented Programming


Evolution of Programming
 Non structured
⚫ Generate spaghetti code
⚫ Sequential and has GoTo
⚫ C O B O L , BAS I C , FO RT R A N
 Structured/Procedural
⚫ Use Subroutine/Function
⚫ improving the clarity, quality, and development time
⚫ C , PA S C A L
 Object Oriented Programming
⚫ Object-oriented programming (OOP) is a programming
language model organized around objects rather than
"actions" and data rather than logic.
⚫ Historically, a program has been viewed as a logical
procedure that takes input data, processes it, and produces
output data.
⚫ Java, C++, C#
Our
Goal
LEARN O B J E C T ORIENTED PROGRAMMING
U S I N G J A VA
Programming Language

 A programming language is a formal


constructed language designed to communicate
instructions to a machine, particularly a
computer.
Java’s Lineage

 Java is related to C++, which is a direct


descendent of C .
⚫ Much of the character of J ava is inherited from these
two languages.
 From C , Java derives its syntax.
 Many of Java’s object-oriented features

were influenced by C++.


Characteristics
 Uses C/C++ basic syntax and basic data types -int, char,
float, double, long, short, byte etc.
 Uses standard C/C++ control structures
 “Pure” O O language
 No stand alone functions -All code is part of a class
 No explicit pointers - uses references
 Uses garbage collection
 J ava is strongly typed
 J ava is normally compiled to a bytecode.
⚫ J ava bytecode is a machine language for an
abstract machine that J ava secure and Portable
 Each platform (or browser) that runs J ava has a J ava
Virtual Machine (JVM) . The J V M executes J ava bytecodes
Why Java

 Platform Independent - Code once run anywhere


⚫ Byte code
 Easy to learn
 Secure

⚫ Byte code & V M


 Free
Java IDE

 Using J D K you can compile and run java


program from command line.
⚫ c:> javac HelloWorld. J ava
 compiling here and
 it will produce HelloWorld.class i.e. bytecode.

⚫ c:>java HelloWorld
 It runs java byte code on native machine
Java IDE
 Creating, Compiling, Debugging and Execution for these
four steps J D K is not user friendly. I D E is provided for
that. A list of IDEs are:
⚫ Eclipse
⚫ Netbeans.
⚫ IntelliJ I D EA

Yo u c a n i n s t a l l I n t e l l i J I D EA u s i n g t h e t u t o r i a l
h t t p s : / / yo u t u . b e / E M LTO M d I z 4 w ? s i = z 0 9 e f 0 t o m G E a 1 R r j
An Example – Hello World

public class HelloWorldExample


{
public static void main( String args[] )
{
System.out.println("Hello World");
}
}
Code Naming Conventions
 All java source file should end with .java
 Each .java file can contain only one public

class
 The name of the file should be the name of

the public class plus ".java"


 Do not use abbreviations in the name of the

class
 If the class name contains multiple words then

capitalize the first letter of each word ex.


HelloWorld.java
Conventions
 Class Naming
⚫ Uses Capitalized word(s) i.e. Title case
⚫ Examples:- HelloWorld, MyList, StudentMark
 Variable and method names
⚫ starts with a lowercase letter and after that use Title
case
⚫ Examples:- variableAndMethodNames, aFloat,
studentName
 Names of constants
⚫ All are capital letters and separated by
underscore.
⚫ Example: N A M E S _ O F _ C O N S TA N T S
Identifiers Rules
 Identifier is a name given to a variable, class, or
method.
 Java identifier

⚫ Can contain letter, number, underscore (_), or dollar


sign ($).
⚫ Cannot start with number.
⚫ Identifiers are case sensitive(var and Var both can
be declared in a program)
⚫ have no maximum length.
⚫ cannot be a keyword, but it can contain a keyword as
part of its name.
Write down whether the following
identifiers are valid or not
Name Valid/invalid comment
myVar# invalid # is not allowed
myVar$ valid
$myVar valid
final invalid keyword
static invalid keyword
finalVar valid Can contain keyword as a part of name
1num invalid Cannot starts with number
main valid Not a keyword

You might also like