IT 206 Quiz Study Set (terms)

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

8 steps in the Object Oriented Approach

1. Identify the object. 2. Identify the instance variables. (attributes) 3. Identify the instance methods. (behaviors 4/5. Write the DDC code (write/run/test) 6. Design the implementation class 7/8. Write the implementation code. (write/run/test)

What is a Data Definition Class?

A blueprint or template defines all the attributes and behaviors associated with an object. Attributes can be of mix data types. (both primitive and reference) NO input/output statements

What is an Instance Variable?

Attributes that belong to a specific instance of a class Should always be private

How are Objects passed?

Similar to arrays, the object's reference values can be passed as arguments/parameters Reference values point to the same set of contents

How is an Object created?

Using the 'new' operator

How can we achieve method Overloading?

3 ways: Different parameter data types Different order of parameters Different number of parameters

How do we handle Exceptions?

3 ways: Exit - which isnt friendly Ignore - which is poor design Deal w/it & Continue - Preferred

What are the Class Behaviors?

4 Types: Constructors Accessors Mutators Special Purpose Methods

What is a Class?

A blueprint or template that defines the attributes & behaviors that an object of that class can have. Attributes in a class can be of mix data types. (both primitive and reference)

How is a Constructor called?

A constructor is invoked automatically when an object is created Cannot call a constructor on an existing object but you can overwrite/create a new object using a n existing reference value

What is an Exception?

A rare event that occurs outside the normal behavior of the code Ex: Invalid number format/invalid number (NFE) Division by Zero Access past end of Array (OutofBounds) Unable to write to output file Missing input file

What is an Array of Objects?

A set of object references

What is a Public Variable?

A variable that can be accessed/updated directly by any class

What is a Private Variable?

A variable that can only be accessed/updated by the class/object it belongs to.

What is a 'final' variable?

A variable that is constant (never changes) These are also static variables There are no setters for 'final' variables

Primitive data types store what?

Actual values pf char, int, double, boolean Boolean (true, false) int = 8 double = 0.0 char = 't' When passing a primitive data type to a method it passes a copy of the actual value

What is a String?

An array of characters String are immutable, once they are created they cannot be changed

What is an Object?

An object represents a specific instance of a class. Each object has the same attributes but with unique values. All objects contain the same behaviors

What is a Checked Exceptions?

Are the exceptions that are checked at compile time. If some code within a method throws a checked exception, then the method must either handle the exception using try/catch or it must specify the exception using throws keyword Ex/ IOException, FileNotFoundException Must use Catch or Declare Must establish a policy in the method

What is an Unchecked Exception?

Are the exceptions that are not checked at compiled time such as runtime errors that a typical program should not have to handle Caused by the programmer Usually logic errors (defects) Ex/ArithmeticException, IllegalArgumentException, NullPointerException

How is a Constructor invoked?

Automatically when an object is created using the 'new' operator is used.

What is a Special Purpose Method

Based on the class, certain methods might be needed. These methods perform special tasks like calculations and special validations (helper methods)

Why are Private Variables used instead of Public?

Because public variables violate information hiding, which can allow any class to manipulate the data directly

Why can't Instance variables/methods be used in Static methods.

Because static methods are shared amongst all instances so there is no way to know which instance variable of an object is being used.

Why are Parallel Arrays avoided in OO?

Because the only reason those arrays are parallel us through programmer logic Parallel arrays can easily get out of sync Instead, an Array of objects is used because correlated data is explicitly together (in the object) rather than logically

Why do we Overload methods?

Because thinking of new names for a method that performs a relatively similar task can get overwhelming.

What are Instance Methods?

Behaviors that belongs to a specific instance

How are Objects stored into an Array?

By instantiating it using the new keyword.

How are Arrays of Objects populated?

By looping through the array

How can external classes access private variables?

By the creation of public methods such as accessors and mutators that will allow external classes to retrieve or change data of those private variables.

What is Lexicographical comparison?

Comparing strings to determine which one is first alphabetically Java is Unicode based 0-9 comes before A-Z which comes before a-z Use compareTo() or compareToIgnoreCase() methods Negative Integer: The contents of the first String are lexicographically before the second String 0: The contents of the first String are lexicographically equal to the second String Positive Integer: The contents of the first String are lexicographically after the second String

When is a UML used?

During the software development life cycle in the design phase

What are the advantages of OO?

Easier to reuse code/easier maintenance Easier to increase an application's functionality Information Hiding - protect the data Data Encapsulation

What does it mean to 'Catch or Declare' an Exception?

Either the method handles the error or propagates it because it doesnt know how to. Catch handle exception in method Declare method can throw exception and force calling function to catch or declare exception in turn

What is Data Encapsulation?

Encapsulation is a requirement in Object-Oriented programming. It's when the implementation details are hidden while only the requested information is made available (public).

A String object is _______. Once it is created, its contents cannot be changed.

Immutable.

What is Information Hiding?

In DDC, data is kept hidden (private) from other classes so no accidental updates can occur. This also allows the class to "police" data validity. Only the specific class can update the data. Methods that belong only in that class are also private DDC will share information using data encapsulation

In a String Class, how would you retrieve an individual character in the array? How about a set of characters?

Individual Character: StringName.charAt(index) Set of characters: substring() method. stringName.substring(0,11)

What is a Specific Constructor?

It is a constructor that has at least one parameter, when at least one attribute value of an object is known at the object creation time.

What is a Default Constructor?

It is a constructor that has no parameters and it is used when no attribute values of an object are known when the object is created

What is a toString Method?

It is a special purpose method used to display a string representation of all the attributes of a constructed object. All classes should have one

What is the Implementation Class?

It is used to instantiate (create) an object of a class It uses accessors and mutators to retrieve and change the values of the attributes (instance variables) of an object

What is a Missing Constructor?

It is when no constructor is specified. JAVA will create a default constructor if one is not provided. Data types are set to there respective default values.

What are the disadvantages of OO?

It's more time consuming that procedural

What is a Mutator (setter)?

Method that is used to manipulate/change an attribute (instance variable) of an object based on information/data given by and external source

What is an Accessor (getter)?

Method that is used to retrieve the value of an attribute (instance variable) of an object and return it to an external class

What does it mean when the methods (primarily instance methods) of the String class are called "attached"?

Methods of the String class are primarily instance methods --- therefore called "attached" to an object. Methods of the character class are static therefore also called 'attached' to the class name.

What are Static Methods?

Methods that are not tied to the object but instead to the class. For example, a method that gets the number of objects created.

When passing arrays, are you passing the contents of the array?

No. You would be passing only the reference value.

What is OO Programming?

Object-Oriented programming is based on the concept of "objects" and their interactions with other "objects. Objects are based on a class, which describes objects with the same behavior and attributes OO still relates to the procedural approach like breaking tasks into sub tasks and reusing methods to handle those tasks.

What is a Static Variable?

Only one variable that is share by all instances of a class. Tied to the class rather than the object Declare by using the 'static' modifier

Complex data types store what?

Reference Values of arrays, String, objects Arrays = shoes [] , String = 'Sally' Object = aEvent When passing a complex data type to a method it passes a copy of the reference

Character Class Methods

Return Boolean's (mostly)

When you forget to initialize the array in the constructor, what kind of error will occur?

Run-time error (NullPointerException). No space in memory has been initialized to store the array contents.

What occurs when an Object reference is not initialized?

Runtime Error of a 'NullPointerException' Cannot call a method that has a null reference

What is Constructor Overloading?

Similar to method overloading Must have unique set of parameters

What are Character methods?

Static methods in the character class Used to manipulate

How can a String be created?

String s = new String ("Hello")' String s = "Hello";

What are the 3 types of errors?

Syntax (compiler): errors that violate the rules of the language Ex/ grammer, format, incorrect data types Logic: errors caused by the user when the expected output doesnt match the actual output Runtime: Illeagal operation Impossible to exec These are treated as "Exceptions"

What does 'Throws' mean?

That a method may throw an exception (warning) Goes in method header Must specify all checked exception that may be thrown

What happens when an Exception occurs?

The statements that follow are skipped and the program is terminated.

If you know an object's initial values, you can set these at ________.

The time of object creation.

What happens when something goes wrong?

Throw an exception

What does 'Throw' mean?

To actually generate an exception (action)

Why do we use 'this' in DDC?

To be able to differentiate instance variables from local variables and parameters.

What does it mean to deal with an Exception?

To print an error message Ask for new data Retry action Exceptions should be handled in the calling method, then decided whether to propagate or not

Why not just make all variables and methods public?

To protect the data from being mistakenly changed (information hiding). To have control over which methods can be used externally. To make the program design easy to maintain. Centralize where and how data and methods can be changed. To control whether a variable value can be changed (datafield encapsulation)

What is UML?

Unified Modeling Language Tool used in development of systems to provide a way to describe system requirements, using a common set of images, regardless of type of system or programming language being employed. This is useful to communicate with business users, programmers, etc. It it also a pictorial/graphical representation of names, properties, actions, and relationships.

How would you find the String length within a String class?

Use the length() method.

What is a Constructor?

Used to initialize instance variables of an object when it's invoked Must have the same name as the class Does not have a return type (therefore it is not a method)

How can a Constructor call another Constructor? Why?

Using 'this(parameters)' Because sometimes the constructors have the same values in the body and this can get very repetitive when having multiple constructors. So instead we call another constructor by passing in the same parameters that constructor requires Calling of another constructor must be the first line Only one constructor can be called within a constructor

What is Ambiguous Invocation?

When a method is invoked and there are two more more possible matches occur and the compiler cannot differentiate. This generates a syntax error

What is method Overloading?

When multiple methods have the same name

How does a DDC communicate with other classes?

communication happens via methods Information/data is passed in as parameters Information/data is pass out as return values

When comparing String contents, what equality comparison commands would you use?

equals() or equalsIgnoreCase() "==" only checks memory locations

String conversions: What is the method to replace one character with another?

replace(oldChar, newChar)

String conversions: What is the method to replace one string with another?

replace(oldString, newString)

String conversions: What is the method to convert all characters to lower case?

toLowerCase()

String conversions: What is the method to convert all characters to upper case?

toUpperCase()

String conversions: What is the method to remove all leading and trailing whitespace?

trim()


Kaugnay na mga set ng pag-aaral

Bio 141, Chapter 5, Integumentary System

View Set

The Farmboy who invented television

View Set

Physics CH. 4 Quiz / Test: Motion and Force: Dynamics

View Set

CNA 270 chapter 9 - WLAN Security Basics

View Set

Medical Surgical Exam 3: ATI practice questions

View Set

India; Tertiary Economic Activities.

View Set

SDSU Anthropology 101 InQuizitive Chapter 11

View Set

Honors U.S. History Chapter 22 Test Preparation

View Set