Module 1
Introduce the Java programming language
Program compilation and execution
Problem solving in general
The software development process
Overview of object-oriented principles
A computer consists of hardware (physical components) and software (programs and data).
Hardware: The physical components doing the computing.
Software: Instructions (programs) that run on hardware.
Programs, also known as applications, execute serially by the hardware.
A programming language defines the lexicon and syntax for writing programs.
Rules govern the arrangement of words and symbols to form valid statements.
Java programming language was created by Sun Microsystems, Inc. and released in 1995.
A Java program is composed of:
One or more classes.
Each class contains one or more methods.
Each method holds program statements.
Every Java application includes a main
method.
**Example Code:
public class Lincoln {
public static void main(String[] args) {
System.out.println("A quote by Abraham Lincoln:");
System.out.println("Whatever you are, be a good one.");
}
}
Comments can be included almost anywhere within the program.
Program Header: public class MyProgram {}
Defines the class.
Main Method Header: public static void main(String[] args) {}
Defines the entry point.
Comments: Explain purposes and processing within the code:
Line Comments (//
)
Block Comments (/*...*/
)
Javadoc Comments (/**...*/
)
Identifiers are names given by programmers in code.
Can include letters, digits, underscores (_), and dollar signs ($), but cannot start with a digit.
Java is case-sensitive: Total
, total
, and TOTAL
are different.
Naming conventions include:
Title case for class names: Lincoln
Upper case for constants: MAXIMUM
Reserved words are predefined words in Java that have specific functions and cannot be used as identifiers.
Whitespace (spaces, tabs, and blank lines) separates symbols and names.
Extra whitespace is ignored, but good formatting enhances readability.
Includes activities like:
Writing the program in a programming language.
Translating it into executable form.
Investigating/fixing errors.
Software tools assist in this development process.
Four programming language levels exist:
Machine Language
Assembly Language
High-Level Language
Fourth-Generation Language
Machine languages are CPU-specific.
Programs must be translated into machine language to execute.
Compiler: Software translating source code into machine language.
Java compiles to bytecode, which is platform-independent.
Java compiler translates source code into bytecode, later interpreted to machine language.
Java programs are thus architecture-neutral due to this unique compilation-execution method.
A development environment comprises all tools like compilers and interpreters needed to create programs.
Integrated Development Environments (IDEs) combine tools (e.g., JDK, Eclipse, NetBeans).
Syntax defines the language structure; semantics define statement meaning.
A syntactically correct program may still have logical errors.
Syntax Errors: Caught at compile-time.
Run-Time Errors: Occur during execution (e.g., division by zero).
Logical Errors: Produce incorrect results despite successful execution.
Multiple activities involved when solving a problem:
Understand the problem.
Design a solution.
Implement and test the solution.
Activities are interlinked and not strictly linear.
Java is object-oriented, using objects to represent real-world entities.
Example: An employee object could manage its own data and behavior.
Objects have:
State: Characteristics (e.g., bank account number).
Behaviors: Actions (e.g., deposits, withdrawals).
Objects are defined by classes, which serve as blueprints.
A class encapsulates data and behaviors, protecting its internal state.
Classes can inherit characteristics from other classes, allowing for organized structures that model real-world relationships.
Introduce the Java programming language
Program compilation and execution
Problem solving in general
The software development process
Overview of object-oriented principles
A computer consists of hardware (physical components) and software (programs and data).
Hardware: The physical components doing the computing.
Software: Instructions (programs) that run on hardware.
Programs, also known as applications, execute serially by the hardware.
A programming language defines the lexicon and syntax for writing programs.
Rules govern the arrangement of words and symbols to form valid statements.
Java programming language was created by Sun Microsystems, Inc. and released in 1995.
A Java program is composed of:
One or more classes.
Each class contains one or more methods.
Each method holds program statements.
Every Java application includes a main
method.
**Example Code:
public class Lincoln {
public static void main(String[] args) {
System.out.println("A quote by Abraham Lincoln:");
System.out.println("Whatever you are, be a good one.");
}
}
Comments can be included almost anywhere within the program.
Program Header: public class MyProgram {}
Defines the class.
Main Method Header: public static void main(String[] args) {}
Defines the entry point.
Comments: Explain purposes and processing within the code:
Line Comments (//
)
Block Comments (/*...*/
)
Javadoc Comments (/**...*/
)
Identifiers are names given by programmers in code.
Can include letters, digits, underscores (_), and dollar signs ($), but cannot start with a digit.
Java is case-sensitive: Total
, total
, and TOTAL
are different.
Naming conventions include:
Title case for class names: Lincoln
Upper case for constants: MAXIMUM
Reserved words are predefined words in Java that have specific functions and cannot be used as identifiers.
Whitespace (spaces, tabs, and blank lines) separates symbols and names.
Extra whitespace is ignored, but good formatting enhances readability.
Includes activities like:
Writing the program in a programming language.
Translating it into executable form.
Investigating/fixing errors.
Software tools assist in this development process.
Four programming language levels exist:
Machine Language
Assembly Language
High-Level Language
Fourth-Generation Language
Machine languages are CPU-specific.
Programs must be translated into machine language to execute.
Compiler: Software translating source code into machine language.
Java compiles to bytecode, which is platform-independent.
Java compiler translates source code into bytecode, later interpreted to machine language.
Java programs are thus architecture-neutral due to this unique compilation-execution method.
A development environment comprises all tools like compilers and interpreters needed to create programs.
Integrated Development Environments (IDEs) combine tools (e.g., JDK, Eclipse, NetBeans).
Syntax defines the language structure; semantics define statement meaning.
A syntactically correct program may still have logical errors.
Syntax Errors: Caught at compile-time.
Run-Time Errors: Occur during execution (e.g., division by zero).
Logical Errors: Produce incorrect results despite successful execution.
Multiple activities involved when solving a problem:
Understand the problem.
Design a solution.
Implement and test the solution.
Activities are interlinked and not strictly linear.
Java is object-oriented, using objects to represent real-world entities.
Example: An employee object could manage its own data and behavior.
Objects have:
State: Characteristics (e.g., bank account number).
Behaviors: Actions (e.g., deposits, withdrawals).
Objects are defined by classes, which serve as blueprints.
A class encapsulates data and behaviors, protecting its internal state.
Classes can inherit characteristics from other classes, allowing for organized structures that model real-world relationships.