Docsity

OOP - Mod 1 - Intro to Java, Lecture notes of Programming Paradigms

Toggle sidebar
bg1
Object-Oriented Programming Module 1 – Lesson 1
Module 1 – Lesson 1 03-26-21
Introduction to Object-oriented
Programming using Java
• Java – old language ; era of Visual Basic ; slowly phasing out – good for
beginners
• Classes – source
• Syntax: public static void main (String [] args)
• Function – it has name and a use; must be called ; accept an input, return an
output
• Main Program – accepts array of strings (String []) ; first to be executed
• String – sequence of words (“Hello World!”)
• Args – argument / variable; customizable; not a strict syntax
• Sytem.out.println – syntax for displaying output (ln – new line)
• Parameter – value of a variable
• .Class – to compile
• Cls – clear screen
• Static – scope, not replicable, one instance to exist in a program
class HelloWorld
{
public static void main (String [] args)
{
System.out.println(“Hello World!”);
}
}
Class
Main Program +
Function
Print
Data Type
(args [0]) → will not display anything
because there’s no defined parameter in
the function
However, this means that you can assign
infinite value for it through input only
until the declared args.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18

Partial preview of the text

Download OOP - Mod 1 - Intro to Java and more Lecture notes Programming Paradigms in PDF only on Docsity!

Introduction to Object-oriented

Programming using Java

  • Java – old language ; era of Visual Basic ; slowly phasing out – good for

beginners

  • Classes – source
  • Syntax: public static void main (String [] args)
  • Function – it has name and a use; must be called ; accept an input, return an

output

  • Main Program – accepts array of strings (String []) ; first to be executed
  • String – sequence of words (“Hello World!”)
  • Args – argument / variable; customizable; not a strict syntax
  • Sytem.out.println – syntax for displaying output (ln – new line)
  • Parameter – value of a variable
  • .Class – to compile
  • Cls – clear screen
  • Static – scope, not replicable, one instance to exist in a program class HelloWorld { public static void main ( String [] args) { System.out.println (“Hello World!”); } } Class Main Program + Function Print Data Type (args [0]) → will not display anything because there’s no defined parameter in the function However, this means that you can assign infinite value for it through input only until the declared args.
  • To display all the inputted arrays without being declared:
  • Objects: can be equal but not the same

IDENTITY vs. EQUALITLY

CLASS

→ Creates object;

  • Name - unique
  • Attributes – properties of a class
  • Methods – using functions
    • “new” – keyword for creating an object and call an object from another

class (Ex: Apple a = new Apple (); ) [CONSTRUCTOR]

  • Assigning identity: → System-defined – syntax
  • With input from user FUNCTION n = Input from the user args = [0] Explanation
  • Float – low accuracy; save low memory (Ex: 3.12346)
  • Double - more precise; store large number (Example: 3.1234567890)
  • EXPLAINATION: Object 2 nd^ Meeting: Encapsulation vs. Information Hiding Encapsulation – not to assign; organizing the elements systematically Information Hiding – set info to private Attributes – lower cases Construction – to call so that an object will be created; always “public”; same with class name
  • Default – no parameters; have to assign a value; “this” – access an attribute in the same class

TO STRING

→ Copy parameter of another object Note: DATA ABSTRACTION

  • Main program – where display or test
  • Class – to maintain .java – codes .class – compiled by the jvm “new” - creating object paired with constructor → “null” – output if the objects is default

→ To restrict the input: Ex. to display only letters, invalid if may number → Validation

Arguments =; values that is passed; call Parameters = terms that we defined as rules in the; implement the function

  • Create more than one object
  • Create two class
  • Data type can be a class

→ CLASS DIAGRAM into CODE Constructor – only called once per object Setter – can be called multiple times for an existing object

To round off: (Ex. 100.0) → ACCESS MODIFIERS

SOFTWARE PACKAGES

  • Manage large software system
  • Conatin classese and subbclassess
  • Only once package per class
  • Default package – directory
  • Track or organize IMPORT STATEMENT
  • Precede all class declaration; find classes to use
  • Can import more than one