Chapter 1 - Introduction Flashcards

(57 cards)

1
Q

Describe the two components of a computer

A

1] Hardware (tangible) - Physical, tangible pieces that support the computing effort

2] Software (intangible) - Consists of programs and the data those programs use

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are programs? What other name do they go by?

A

Programs, also called applications, are a series of instructions that the hardware executes one after another

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a programming language?

A

Programs are written in a particular programming language that uses specific words and symbols to express the problem solution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are programming statements?

A

Instructions that are carried out when a program is executed. The rules of the programming language define how words and symbols can be combined into programming statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Provide a brief background of Java.

A
  • A relatively new programming language developed in early 1990s by James Gosling of Sun Microsystems
  • Java has gone through changes since its creation. The most recent Java technology is the “Java 2 Platform” which includes Java 2 Platform, Standard Edition (J2SE)
  • Java is an object oriented programming language -> objects are fundamental elements of the language
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does it mean to say something is deprecated?

A

Deprecated means that something is considered old fashioned and not to be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the Java API (AKA The Standard Class Library)?

A

A library of extra software we can use when developing programs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the meaning of a software library?

A

(1) When talking about a program or programming a software library refers to a collection of files, programs, routines, scripts or functions that can be referenced in the programming code
(2) A software library is a collection of software owned by a single company

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the purpose of comments in a Java program?

A
  • First few lines of a program are comments
  • Comments don’t affect what the program does but are included to make the program easier to understand by humans
  • Can and should be included throughout a program to clearly identify the purpose of the program
  • Comments allow programmers to communicate their thoughts independent of the code
  • Comments can be any text whatsoever as they do not affect how the program executes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is documentation?

What is inline documentation?

A

Documentation - Any written comments or documents, including a user’s guide and technical references
Inline Documentation - Comments included in a program (i.e. inside the source code)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
What is a class definition?
What makes up the class definition?
A

The rest of any program (after any comments at the beginning) is a class definition and goes from the first opening brace ({) to the final closing brace (}) on last line of the program.

A class definition is made up of:

  • Method: A group of programming statements that is given a name
  • Main Method: A method with the name main where processing in a Java program always begins
  • Main method definition is always proceed by “public”, “static” and “void”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does “invoke” or “call” mean?

A

Invoke or call means to execute a method, i.e. “invoke a method” or “call a method”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can main methods contain other methods?

A

Yes, for e.g. we see the println method used often within the text:

public static void main (string[] args)
{
System.out.println(“A quote by Abraham Lincoln:”);
System.out.println(“Whatever you are, be a good one”);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the println method?

A

Println is a method that prints specified characters to the screen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Why are methods part of the system.out object not defined in Java programs?

A

Because methods part of the system.out object are part of the Java Standard Class Library so can just be referenced in the code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the two ways of writing inline comments?

A

1]
(A) Begin with a double slash & go to the end of the line, eg:
// This is a comment
(B) Comment and code on same line
system.out.println(“Monthly Report”); // always us this title

2] Anything between slash asterisks (/) & (/), eg:
/* This is another comment /
This type of comment can extend multiple lines, eg:
/

This is one comment
That spans several lines
*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are identifiers and reserved words?

A

-Identifiers are the various words used when writing programs
-There are three categories of identifiers:
(1) Words that we make up when writing a program. E.g. Lincoln, the name of a class in the text’s examples
(2) Words that another programmer chose.
E.g. predefined code like println or system or out from the Java Standard Library (not technically part of the Java language)
(3) Words that are reserved for special purposes in the language
I.e. Identifiers that have a special meaning in a programming language and can be used only in pre-defined ways e.g. class, public, static, void

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What are the rules for “made up” identifiers

A

-Can have any combination of
(1) Letters
(2) Digits
(3) Underscore character ( _ )
(4) Dollar sign ( $ )
-But cannot begin w/ a digit
-Identifiers are case sensitive
E.g. total, Total, ToTal, are all different identifiers

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What should you consider when it comes to the readability of identifiers you use?

A

Identifiers should be as readable and descriptive as possible. Avoid meaningless names, identifiers that are too long, and abbreviations that others and even yourself may have trouble understanding months later.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is white space?

A
  • Consists of blanks, tabs & new line characters
  • White space is important because it can be used to emphasize parts of the code & can make a program easier to read
  • White space is ignored by computer except when used to separate words -> i.e. it does not affect execution of the programs
  • Lines of program should be divided in logical places
  • Certain lines should be indented so that the program’s structure is clear
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the different programming language levels?

A
  • Machine language
  • Assembly language
  • High level languages
  • Fourth generation languages
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Describe what is machine language?

A
  • For a program to run on a computer, it must be expressed in the computer’s machine language
  • Each CPU has its own language
  • Machine language instructions can accomplish only simple tasks, e.g. it might take four machine language instructions to add two numbers. However, a computer can do millions of these instructions in a second.
  • Machine language code is expressed as a series of binary digits and is extremely difficult for humans to read and write
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is assembly language?

A
  • Replaced binary digits with mnemonics, short English like words
  • Cannot be directly executed on a computer, needs to first be translated into machine language
  • Considered to be an “improvement” over machine language from a programmer’s perspective, but still tedious
24
Q

What are low-level languages?

A
  • What programmer use to write software
  • High level language expressed in English like phrases and thus easier to read and write
  • One high level programming language statement can accomplish many, perhaps hundreds of machine language instructions
  • “high level” comes from the fact that programming statements expressed in a way far removed from machine language that is ultimately executed
  • Examples of high level languages include Java, ADA, C++, Small T all and many others
25
What are fourth generation languages?
-Considered to operate at an even higher level that’s high level languages
26
What are software tools?
- Special programs to help with developing new programs | - Examples include an editor, compiler and interpreter
27
What is an editor?
Where you type a program and store it in a file
28
What is a compiler?
-Translates code in one language to code in another Source Code —> Compiler —> Target Language (The original code) Translates (Could be machine language or some intermediate low-level code like Java bytecode)
29
What is an interpreter?
- interweaves translation and execution activities - a small part of source code translated, then executed, then next small part translated then executed - results in program running slower Java Source Code | | \ / Java Compile —> Java Bytecode / \ / \ \ / \ / Java Interpreter Bytecode Compiler | | \ / Machine Code
30
What is a development environment?
- A set of tools to create, test, and modify a program - Contains certain key tools like a Java compiler and interpreter - Some include “debuggers”, which helps find errors in a program - Other tools may include: - Documentation generators - Archiving tools - Tools to help visualize program structure
31
What’s an IDE and an SDK? What’s the difference?
Integrated Development Environment (IDE) - Integrate various tools into one software program and often has more features than SDK - Often more user-friendly that an SDK as it has a graphical user interface (GUI) and windows, menus, buttons, etc Software Development Kit (SDK) -Only includes necessary building blocks for developing applications (compilers, libraries, etc) -Sun Microsystems provides the Java Development Kit - What’s the difference between an SDK and IDE? -Basically IDE is a more user friendly version of an SDK with a GUI and some additional features
32
What is syntax?
- Syntax are the rules of a language that dictate how vocabulary elements can be combined to form statements. - Eg in Java an identifier cannot begin with a digit -> this is a syntax rule - During compilation, all syntax rules are checked
33
What are semantics
- Semantics define what will happen when a statement is executed. Generally programming languages are unambiguous and there is only one interpretation for each statement - The “meaning” of a statement
34
What is the difference between the semantics of programming languages vs. natural languages?
- Semantics or the meaning of a statement in a computer language cannot be ambiguous, otherwise a computer would not know how to carry out the instruction - Natural languages like English are inherently ambiguous like “fruit flies like a banana”
35
What are the tree types of errors in computer programs?
- Compile-Time Error - Run-Time Error - Logical Error
36
What is a compile time error?
- Any error identified by the compiler - One type is a “syntax error” where a statement does not conform to syntactic rules of the language - Other errors happen when syntax correct but trying to do something the language doesn’t allow - No executable created when this error occurs
37
What is a run-time error?
- Occurs when program executes and calls program to terminate abnormally - E.g. attempting to divide by zero, the program “crashes”, i.e. execution is halted - “robust” programs are able to avoid as many run-time errors as possible - “exceptions” are run-time problems that can be caught and death with accordingly
38
What are logical errors?
- Compiles and executes without issue but yields incorrect results - Eg a graphical button does not appear in right place - Programmers must thoroughly compare expected results vs actual results that occur - If defects found in program, they must be traced back to source in the code. - Debugging: the process of finding and correcting defects in a program
39
What are the steps of problem solving in the context of software development?
Problem solving consists of multiple steps: (1) Understand the problem (2) Design a solution (3) Consider alternatives (4) Implement the solution (5) Test the solution & fix any problems that exist
40
What is a problem domain?
- The real world issues key to our solution - E.g. if writing a program to score a bowling match, then the problem domain includes the rules of bowling - Developing a good solution requires we thoroughly understand the problem domain
41
What does “breaking things down” mean in the context of software development and problem solving?
- Key to designing a problem solution is breaking it down into manageable pieces. - When developing software, we don’t write one big program. We design separate pieces that are responsible for certain parts of the solution and then we integrate them with the other parts
42
What is implementation?
- The process of actually writing the program, ie putting the solution we designed in a usable form - Writing the code, ie implementation, is only one stage of software development. Ie “implementing the design in a particular programming language”
43
What are the 4 main software development activities?
(1) Establishing the requirements (2) Creating a design (3) Implementing the design (4) Testing -These steps are almost never linear, they overlap and interact
44
Describe what software requirements are.
- What a program must accomplish - Indicates tasks a program should perform but not how it performs them - Requirements are a clear expression of the problem to be solved - Client often provides initial set of requirements. But these are often vague, ambiguous and even contradictory - Software developers must work with the client to refine the requirements until all key decisions about what the system will do have been addressed - Requirements establish the characteristics that make the program useful for the end user. They may also apply constraints, such as how fast a task must be performed
45
Describe software design.
- How a program will accomplish its requirements - Specifies classes and objects needed in a program and defines how they interact - Low level design issues deal with how individual methods accomplish their tasks
46
What is implementation?
- The process of writing the source code that will solve the problem - Translating the design into a particular programming language - Too many programmers focus on implementation exclusively, when it is least creative of development activities. - The important decisions should be made when establishing the requirements and creating the design
47
What is testing in the context of software development?
- The act of ensuring a program will solve the targeted problem - Often involves running a program multiple times and carefully scrutinizing the results
48
What is an object in the context of object oriented programming (the dominant approach in commercial software development)?
- A fundamental entity in Java programs - Java software development can be thought of as defining objects that interact with each other - Objects can represent real world entities and thus map our programs to real situations making them very effective for problem-solving. - The point of software development in the first place for eg an object could represent an employee in a company or a bank account
49
What is the “state” of an object?
The state of an object refers to the characteristics that currently define the object, e.g. a bank account (the object) has an account balance (its state)
50
What are the “behaviours” of an object?
- Activities associated with the object - For bank account, could be ability to make deposits and withdrawals - The methods of an object define its potential behaviours
51
What is primitive data?
Primitive data are fundamental values such as numbers and characters
52
What are attributes (in the context of objects)?
- The values an object stores internally, could be primitive data or other objects - For e.g. a bank account may store a floating point number (a primitive value) that represents the balance of the account - Other attributes could be name of the account owner etc. - Collectively, the values of an object’s attributes define its current state
53
What is a method? (Give more detailed explanation referencing methods and their relationship to objects)
- A group of programming statements that is given a name - A set of methods is associated with an object - The methods of an object define its potential behaviours - To define ability to make a deposit in a bank account, we define a method containing programming statements that will update the account balance accordingly
54
What is a class? (Detailed explanation with relation to objects)
-An object is defined by a class -A class is the model or blueprint from which an object is created -But a class is no more an object than a blueprint a house -A class is a blueprint of an object. -A class establishes the kind of data an object of that type will hold -Defines the methods that represent the behaviour of such objects -Once a class has been defined, multiple objects can be created from that class JUST LIKE —> when a blueprint has been drawn, multiple houses can be created E.g. once we define a class to represent the concept of bank account, we can create multiple objects to represent specific, individual bank accounts. Each bank account object will keep track of its own balance.
55
What is encapsulation?
- Each object protects and manages its own information - An object should be self-governing - Changes to the state of the object should be accomplished by that object’s methods - We should design an object so that other objects cannot “reach in” and change its state
56
What is inheritance?
``` Classes being created from other classes, ie. the definition of one class can be based on another class that already exists —> this is a form of “software re-use.” -Create hierarchies where attributes and methods defined in one class are inherited by its children (derived classes) ```
57
What is Polymorphism?
- The idea we can refer to multiple types of related objects over time in consistent ways - Allows for the design of powerful and elegant solutions to problems that deal with multiple objects