0% found this document useful (0 votes)
2 views

CSC111 (KSU) Core Java Programming Concepts · GitHub

The document outlines the core Java programming concepts covered in the CSC111 course at KSU, including an introduction to Java, core Java concepts, control flow, and objects and methods. It details essential topics such as data types, variable scope, control structures like loops and conditionals, and object-oriented programming principles. The document serves as a comprehensive guide for understanding the foundational elements of Java programming.

Uploaded by

nmnq2015
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

CSC111 (KSU) Core Java Programming Concepts · GitHub

The document outlines the core Java programming concepts covered in the CSC111 course at KSU, including an introduction to Java, core Java concepts, control flow, and objects and methods. It details essential topics such as data types, variable scope, control structures like loops and conditionals, and object-oriented programming principles. The document serves as a comprehensive guide for understanding the foundational elements of Java programming.

Uploaded by

nmnq2015
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Sign in Sign up

Instantly share code, notes, and snippets.

naserowaimer / CSC111(KSU)-
CoreJavaProgrammingConcepts.m
d
Created 7 hours ago

Embed Clone
<script src="https://gist.github.com/nas

Code Revisions 1

CSC111 (KSU): Core Java Programming Concepts

CSC111(KSU)-CoreJavaProgrammingConc Raw

epts.md

Hierarchical Summary of Topics


Covered in the course

1. INTRODUCTION TO JAVA

Computer Basics [1]


Components [1]
Hardware: Physical parts
[1]
Software:
Programs/Instructions [1]
Typical Components [1]:
Input: Keyboard, etc.
[1]
Output: Screen, etc.
[1]
Processor [1]
Memory [1]
Main: Working
storage [1]
Auxiliary: Long-
term storage [1]
Data Encoding: 1s and 0s
represent all data [2]
Files [2]:
Groups of bytes on
auxiliary storage [2]
Organized in directories [2]
Java programs stored as
files, copied to main
memory to run [2]
Operating System (OS) [3]:
Manages computer
operation [3]
Starts programs [3]
Examples: Windows,
MacOS, Linux, UNIX [3]
Programming Languages [3]:
High-level: Easier for
humans, need compilation
[3]
Examples: Java, C++,
Python, etc. [3]
Compiler: Translates high-
level to low-level
(runnable) code [3]
Java History [4]:
Started 1991, Sun
Microsystems, James
Gosling [4]
Initially for appliances,
challenging due to chip
variety [4]
Solution: Intermediate
language (byte-code) [4]
Byte-code: Runs on Java
Virtual Machine (JVM) [4]
JVM exists on many
systems, making Java
portable [4]
Programming Basics [5]:
Approaches [5]:
Structured/Modular
Programming [5]:
Divide problem
into sub-problems
[5]
Solve each,
combine solutions
[5]
Examples: Pascal,
Fortran, C [5]
Object-Oriented
Programming (OOP)
[6]:
Models program
as interacting
objects [6]
Object: Performs
actions, has data
[6]
Method: Actions
an object can
perform [6]
Class: Template
for objects of the
same kind [6]
OOP techniques
apply to many
languages,
including Java [6]
Algorithm [7]:
Sequence of steps to
solve a problem [7]
Must be complete and
precise [7]
Expressed in English
or pseudocode [7]
Software Reuse:
Combining existing
components [7]
Reduces development
time, improves
reliability [7]

2. CORE JAVA CONCEPTS

Variables and Expressions [8]:


Variable: Stores data, has a
name, type, and value [8]
Value can change during
program execution [8]
Implemented as memory
locations [8]
Named Constant: Value cannot
change [8]
Declaring Variables [9]:
Must be done before use [9]
Specify name and type [9]
Type: Determines what values
can be stored and memory size
[9]
Java Identifiers [9]:
Names for variables, classes,
methods, etc. [9]
Rules [9]:
Letters, digits, underscore,
dollar sign allowed [10]
Cannot start with a digit
[10]
Cannot be a reserved word
[10]
No spaces or special
characters [11]
Case-sensitive [11]
Reserved Word (Keyword):
Predefined meaning [10]
Examples: int , public ,
class [11]

Naming Conventions [11]:


Classes: Start with uppercase
[11]
Primitive types: Start with
lowercase [11]
Variables: Start with lowercase,
use camelCase [11]
Named Constants: All
uppercase, use underscores
[12]
Variable Scope: Where a variable is
accessible [12]
Declare just before use or at
block start [12]
Data Types [12]:
Class Type: For objects with
data and methods [13]
Primitive Type: Simple, non-
decomposable values [13]
Examples: int , double ,
char , boolean [13]

Primitive Types [13]:


Integer: byte , short ,
int , long [13]

Floating-point: float ,
double [13]

Character: char [13]


Boolean: boolean
(true/false) [13]
Assignment Compatibilities [14]:
Java is strongly typed: Restricts
assigning values of
incompatible types [14]
Type conversions sometimes
possible [14]
Type Casting: Explicitly
converting between types [14]
Arithmetic Operations: + , - , * ,
/ , % [14]
Operator Precedence: Rules
for order of operations [14]
Specialized Assignment
Operators: += , -= , *= , /= ,
%= [14]

Increment/Decrement
Operators: ++ , -- [14]
Strings [15]:
String: Sequence of
characters, enclosed in double
quotes [15]
Empty String: Contains no
characters, length is 0 [15]
String Indices: Start at 0 [16]
String Methods [17]:
length() : Returns length
of string [17]
charAt(index) : Extracts
character at given index
[17]
indexOf(char) : Finds
first occurrence of
character [17]
indexOf(char, pos) :
Finds character starting at
given position [17]
indexOf(String) : Finds
first occurrence of
substring [18]
indexOf(String, pos) :
Finds substring starting at
given position [18]
substring(beginIndex) :
Extracts substring from
given index to end [19]
substring(beginIndex,
endIndex) : Extracts
substring between given
indices [19]
toLowerCase() : Converts
to lowercase [19]
toUpperCase() : Converts
to uppercase [19]
equals(String) : Checks
if strings are equal [19]
equalsIgnoreCase(String
) : Checks equality
ignoring case [19]
Escape Characters: Special
characters within strings [20]
Examples: \" , \n , \\
[20]
Unicode Character Set:
Encodes characters from
various languages [20]
Input and Output [21]:
Screen Output [21]:
System.out.println(data
) : Prints data and a
newline [21]
System.out.print(data)
: Prints data without a
newline [22]
Concatenation Operator
( + ): Combines strings and
data [21]
Keyboard Input [22]:
Use the Scanner class
[23]
Import
java.util.Scanner [23]

Create a Scanner object:


Scanner keyboard = new
Scanner(System.in);
[23]
Read data using methods
like nextInt() ,
nextDouble() ,
nextLine() [23]

Formatted Output [24]:


Use
System.out.printf(forma
tString, argumentList);
[24]
Format String: Contains
text and format specifiers
[24]
Argument List: Values to
be formatted [24]
Format Specifier: Starts
with % , indicates data
type and formatting [24]
Examples: %d , %f ,
%c , %s , %e , %n ,
%% [24]

Width and Precision:


Control spacing and
decimal places [25]
%6d : Integer with
width 6 [25]
%6.3f : Floating-point
with width 6 and 3
decimal places [25]
Flags: Left-justify, add
signs, etc. [26]
%-6s : Left-justified
string with width 6
[26]
Documentation and Style [27]:
Naming: Use meaningful
names, follow conventions [27]
Comments: Explain code, use
for clarity [27]
Start program files with
header comment [28]
Comment only what needs
explanation [28]
Indentation: Use consistently
to show code structure [28]
Named Constants: Improve
readability and maintainability
[29]
Declare using public
static final [29]

Example: public static


final double PI =
3.14159; [29]

3. CONTROL FLOW

Branching [30]:

if-else Statement [30]:


Executes different code
blocks based on a
condition [30]
Syntax [30]:

if (boolean_expression) {
// Code to execute if tr
} else {
// Code to execute if fa
}

Boolean Expression:
Evaluates to true or false
[31]
Comparing Strings: Use
equals() or
equalsIgnoreCase() [31]
CRITICAL NOTE: Do
not use == to
compare string objects
[32]
Nested if-else: if-else
statements inside each
other [33]
CRITICAL NOTE: Pay
attention to matching
else blocks [34]
Each else
matches the
closest
unmatched if
[34]
Use braces to
clarify nesting
[34]
Multibranch if-else: Chain
of if-else if statements
[35]
Syntax [35]:

if (condition1) {
// Code 1
} else if (condition2) {
// Code 2
} else if (condition3) {
// Code 3
} ... else {
// Default code
}

switch Statement [36]:


Executes code based on
the value of an integral
expression [36]
Syntax [36]:

switch (expression) {
case value1:
// Code 1
break;
case value2:
// Code 2
break;
...
default:
// Default code
}

Controlling Expression:
Value to be matched [36]
Case Label: Constant
value to compare with [36]
break Statement: Exits the
switch block [37]
CRITICAL NOTE:
Omitting break leads
to fall-through [37]
default Case: Executed if
no match found [37]
Conditional Operator ( ?: ):
Shorthand for simple if-else
[30]
Syntax: condition ?
value_if_true :
value_if_false [30]

exit Method: Terminates the


program [30]

Loops [38]:

Loop: Repeats a block of code


[38]
Body: Statements to be
repeated [38]
Iteration: One execution of
the loop body [38]
while Loop [38]:
Repeats as long as a
condition is true [38]
Syntax [38]:

while (boolean_expression) {
// Loop body
}

CRITICAL NOTE: Ensure


the condition eventually
becomes false to avoid
infinite loops [39]
do-while Loop [40]:
Repeats at least once,
checks the condition at the
end [40]
Syntax [40]:

do {
// Loop body
} while (boolean_expression)

for Loop [41]:


Typically used for counter-
controlled loops [41]
Syntax [41]:

for (initialization; conditi


// Loop body
}

Initialization: Executes
once at the beginning [41]
Condition: Checked before
each iteration [41]
Update: Executed after
each iteration [41]
for Statement Variations
[42]:
Multiple initializations
or updates using
commas [42]
Empty body using a
semicolon [42]
Omitting parts of the
control statements
[42]
CRITICAL NOTE: Be
careful to avoid infinite
loops [43]
Nested Loops: Loops inside
other loops [44]
break Statement in Loops:
Exits the loop immediately [45]
CRITICAL NOTE: Use
sparingly, can make code
harder to understand [45]
continue Statement in Loops:
Skips to the next iteration [45]
CRITICAL NOTE: Not
recommended, can
complicate logic [45]

4. OBJECTS AND METHODS

Classes and Methods [46]:


Class: Blueprint for objects
[46]
Method: Defines an action for
an object [47]
Void Method: Does not
return a value [47]
Value-Returning Method:
Returns a value of a
specific type [47]
Calling Methods:
objectName.methodName(a
rguments); [47]
Void methods are
called as statements
[47]
Value-returning
methods are used in
expressions [47]
Defining Methods [48]:
Methods are defined inside
classes [48]
Syntax [48]:

public return_type method_na


// Method body
}

return Statement: Exits


the method and returns a
value [49]
CRITICAL NOTE: All
paths in a value-
returning method
should have a return
[49]
return; can be used
in void methods to exit
early [50]
Instance Variables: Data
associated with an object [46]
Information Hiding [51]:
Encapsulation: Bundling
data and methods that
operate on that data [51]
Data Hiding: Making
instance variables private
[51]
Protects data from
accidental
modification [51]
Accessor Methods
(Getters): Provide read-
only access to private data
[52]
Mutator Methods
(Setters): Allow controlled
modification of private data
[52]
Can include validation
to ensure data
integrity [52]
Objects and References [53]:
Variables of Class Type:
Store references (memory
addresses) to objects [53]
Not the objects
themselves [53]
equals Method: Used to
compare object content
[32]
CRITICAL NOTE: Do
not use == to
compare objects [32]
Boolean-Valued Methods:
Return true or false [54]
Parameters of Class Type:
References are passed to
methods [54]
Changes to the object
affect the original
object [54]
Constructors [55]:
Constructor: Special
method called when an
object is created [55]
Same name as the
class [55]

You might also like