Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

An introduction to object-oriented programming using Java. It covers topics such as classes, functions, methods, constructors, access modifiers, and import statements. The document also includes code examples and explanations of syntax and terminology. suitable for beginners and provides a foundation for further study of object-oriented programming.

Typology: Lecture notes

2020/2021

Available from 04/02/2022

gwen-hermo
gwen-hermo 🇵🇭

10 documents

1 / 24

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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 numberValidation

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