Revision Final Exam PDF

Title Revision Final Exam
Author Hailey Le
Course Intro To Comp Sci I
Institution Purdue University Fort Wayne
Pages 1
File Size 73 KB
File Type PDF
Total Downloads 86
Total Views 184

Summary

Finals Review...


Description

Revision Final Exam 

Chapter 6: A first look at classes A. Lecture 6.1: 1. Objects: - exists in memory and perform specific tasks (ex: String objects hold Strings, Scanner objects let us read from files) - When an object is needed, programs create the object type they need and calls methods - 2 general capabilities: + can store data. The pieces of data are known as fields + can perform operations. These operations are known as methods 2. Object-oriented programming: - OOP is based on object creation - Objects melt data and the procedures that act on them - When approaching a problem with OOP, ask: + What services does the program need? + What objects provide these service? (Do we need to write any?) + What operations should the objects perform? (What methods are needed?) 3. Classes: - Def: is code that describes a particular kind of object, specifies the data items an object can hold and the actions an object can perform (fields and methods) - Are like blueprints used to make specific types of objects - can be used to create many objects. Each object is called an instance of the class 4. How objects work: - Scanner and String examples - Java API classes: provides a large number of classes, with a variety of uses. Ex: Scanner, Random, PrintWriter, File, String, DecimalFormat,… 5. Objects broken down: - The memory: Primitive data types variables are chunks of memory that hold the value (ex: int x =5  x is somewhere in the memory that holds the value 5) - Objects are more involved: Object variables hold the memory address reference to the object. Object itself exists elsewhere - Ex: Random rand = new Random(); + Random rand makes a variable called rand of type Random + new is the keyword which signals Java that a new object needs memory + Random() creates a new random object and returns the memory address where it’s located, assigning the memory address of the object to rand 6. Access specifiers/ modifiers: - Java gives us access specifiers which dictate how a field or method can be accessed - public methods/ fields (ex: public static void methods) can be accessed by any code - private methods/ fields can only be accessed by the class in which they are defined/ declared - UML...


Similar Free PDFs