hello quizlet
Home
Subjects
Expert solutions
Create
Study sets, textbooks, questions
Log in
Sign up
Upgrade to remove ads
Only $35.99/year
EX2: WK7 Object Oriented Programming
Flashcards
Learn
Test
Match
Flashcards
Learn
Test
Match
Terms in this set (25)
Information hiding
- The concept of keeping data private
- Data can be altered only by methods you choose and only in ways that you can control
When a class serves as a superclass - Subclasses inherit all data and methods of the superclass ■ Except private members of the parent class are not accessible within a child class's methods
Keyword protected
- Provides an intermediate level of security between public and private access - Can be used within its own class or in any classes extended from that class - Cannot be used by "outside" classes
■ static methods
■ final methods
■ Methods within final classes
3 Methods You Cannot Override
A subclass cannot override methods declared final in the superclass
Subclass Can or Cannot Override final Methods in Its Superclass
final modifier
- Does not allow the method to be overridden
Advantages to making the method final
- The compiler knows only one version of the method exists - The compiler knows which method version will be used - A program's performance can be optimized by removing calls to final methods
Inlining the code:
each method call is replaced with the expanded code of the method's definition
When a class is declared final:
- All of its methods are final regardless of which access modifier precedes the method name - It cannot be a parent class
Exceptions
- Unexpected or error conditions - Not usual occurrences - Causes: ■ The program issues a call to a file that does not exist ■ The program attempts to write to a full disk or unformatted disk ■ The user enters invalid data ■ The program attempts to divide a value by 0 ■ The program tries to access an array with a subscript that is too large or too small
Error
Serious errors from which a program usually cannot recover (insufficient memory to execute a program, cannot locate a required class)
Exception
- unusual errors that arise while program is executing and can recover (illegal arithmetic operations, array subscript issue)
Exception handling
X provides a more elegant solution for handling error conditions
Fault-tolerant
- Designed to continue to operate when some part of the system fails
Robustness
- Represents the degree to which a system is resilient to stress
try block
- A segment of code in which something might go wrong - Attempts to execute ■ Acknowledges an exception might occur
A X includes: - The keyword X - Opening and closing curly braces - Executable statements, which might cause an exception
catch block
- A segment of code - Immediately follows a try block - Handles an exception thrown by the try block preceding it - Can "x" an Object of type Exception or an Exception child class.
Includes: -Opening and closing parentheses ■ An Exception type ■ A name for an instance of the Exception type - Opening and closing curly braces ■ Statements to handle the error condition
throw statement
Sends an Exception object out of a block or method so it can be handled elsewhere
"Catch-all" block
- Accepts a more generic Exception argument type: catch(Exception e)
Unreachable code
- Program statements that can never execute under any circumstances
finally block
- Use for actions you must perform at the end of a try...catch sequence - Use to perform cleanup tasks - Executes regardless of whether the preceding try block identifies an exception
The X executes no matter what outcome of the try block occurs - The try ends normally - The catch executes - The uncaught exception causes the method to abandon prematurely
When the try code fails
- It throws an exception - The Exception object is caught - The catch block executes ■ Control passes to statements at the end of the method
Advantages of Exception Handling
Java's object-oriented, error-handling technique - Statements of the program that do the "real" work are placed together, where their logic is easy to follow - Unusual, exceptional events are grouped and moved out of the way ■X is flexibility in handling of error situations ■ Appropriately deal with exceptions as you decide how to handle them
Unchecked exceptions
- Inherit from the Error class or the RuntimeException class - You are not required to handle these exceptions ■ You can simply let the program terminate ■ An example is dividing by zero
Checked exceptions
- Programmers should anticipate X
- Programs should be able to recover from them
Call stack
- The memory location where the computer stores the list of method locations to which the system must return
When a method throws an exception:
- The exception is thrown to the next method up the X
- Methods are allowed to handle exceptions wherever the programmer has decided it is most appropriate ■ Including allowing the operating system to handle the error
Sets found in the same folder
EX2: WK5 Object Oriented Programming
24 terms
EX2: WK6 Object Oriented Programming
21 terms
EX2: WK8 Object Oriented Programming
25 terms
EX1: WK1 Programming Basics
23 terms
Other sets by this creator
EX1: WK4 Object Oriented Programming
15 terms
EX1: WK3 Object Oriented Programming
17 terms
EX1: WK2 Object Oriented Programming
34 terms
EX2 Ch 14 Installation & Operations
7 terms
Recommended textbook solutions
Information Technology Project Management: Providing Measurable Organizational Value
5th Edition
•
ISBN: 9781118898208
Jack T. Marchewka
346 solutions
Information Technology Project Management: Providing Measurable Organizational Value
5th Edition
•
ISBN: 9781118911013
(2 more)
Jack T. Marchewka
346 solutions
C++ Programming: From Problem Analysis to Program Design
8th Edition
•
ISBN: 9781337102087
(2 more)
D. S. Malik
1,889 solutions
Information Technology Project Management: Providing Measurable Organizational Value
5th Edition
•
ISBN: 9781118898208
Jack T. Marchewka
346 solutions
Other Quizlet sets
Frankenstine essay
12 terms
Bradiarritmia
28 terms
Psych Final Exam: Nociception
50 terms
HYG 202 TEST #3
32 terms