OOP'24 Lab Collection PDF
Document Details
Uploaded by ProfuseRetinalite599
Tags
Summary
This document is a collection of OOP'24 lab materials, including topics such as Java programming, arrays, and loops.
Full Transcript
Object Oriented Programming Lab 1 Object Oriented Programming Lab 2 Arrays in Java Agenda Loops in Java Main OOP Vocabulary Decision Making in Java: if – else, switch, break and continue. Introduction to OOP Class...
Object Oriented Programming Lab 1 Object Oriented Programming Lab 2 Arrays in Java Agenda Loops in Java Main OOP Vocabulary Decision Making in Java: if – else, switch, break and continue. Introduction to OOP Classes and objects Class constructor Encapsulation Access modifiers and field modifiers public, protected, default, private Static (field and method), final field Hands-on Arrays in Java DataType[] variableName= new DataType[Number]; ❑ In Java, all arrays are dynamically allocated, means you can read the size as an input from the user and then allocate the array. ❑ Obtaining an array is a two-step process: 1. Variable declaration: int myArr[ ]; or int[ ] myArr; int multiArr[ ][ ]; or int [ ][ ] multiArr; 2. Memory allocation (Instantiating an Array): myArr = new int; 4 multiArr = new int; Loops in Java 1. While: while (x_IsTrue) { // do these stetments } 2. Do while: do { // do these statements } while (x_IsTrue); 3. For: Foreach: for(int i=0; i