PROGRAMMING

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/104

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

105 Terms

1
New cards

Java

is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices and many others.

2
New cards

java

 The rules and syntax of _____ are based on the C and C++ languages

3
New cards

Primary goal of java

"write once, run anywhere.

4
New cards

java

was initially developed by James Gosling at Sun Microsystems in the early 1990s. Gosling named the project "Oak" after an oak tree that stood outside his office window.

5
New cards

Variables

refer to Containers for storing data (changeable values)

6
New cards

Constants

refer to fixed values using final.

7
New cards

underscore _ or dollar sign $ characters,

Variable names should not start with ________ even though both are allowed

8
New cards

mnemonic- that is, designed to indicate to the casual observer the intent of its use.

The choice of a variable name should be

9
New cards

One-character variable names

should be avoided except for temporary "throwaway" variables.

10
New cards

i, j, k, m, and n

Common names for temporary variable for integers

11
New cards

c, d, and e

Common names for temporary variables for characters

12
New cards

Data type

a classification that dictates what kind of values a variable can hold in programming, and how the computer should interpret those values.

13
New cards

Primitive

specifies the type of a variable and the kind of values it can hold

14
New cards

Categories of Data Types:

Primitive - specifies the type of a variable and the kind of values it can hold

Non-primitive - such as String, Arrays and Classes

15
New cards

Non-primitive

- such as String, Arrays and Classes

16
New cards

byte

Stores whole numbers from -128 to 127

17
New cards

short

Stores whole numbers from -32,768 to 32,767

18
New cards

int

Stores whole numbers from -2,147,483,648 to 2,147,483,647

19
New cards

long

Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

20
New cards

float

Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits

21
New cards

double

Stores fractional numbers. Sufficient for storing 15 to 16 decimal digits

22
New cards

boolean

Stores true or false values

23
New cards

char

Stores a single character/letter or ASCII values

24
New cards

 Open CMD  Locate your java code Compile your code (javac file name)  Run your code (java class name)

How to run your java program?

25
New cards

VARIABLES

A variables can be considered as a name given to the location in memory where values are stored.

26
New cards

Use only the characters 'a' through 'z', 'A' through 'Z', '0' through '9', character '_', and character '$'. A name can’t contain space character. Do not start with a digit. A name can be of any length. Upper and lower case count as different characters. So SUM and Sum are different names. A name can not be a reserved word. A name must not already be in use in this part of the program.

VARIABLE NAMES AND KEYWORDS DOS AND DONT

27
New cards

reserved word

is a word which has a predefined meaning in Java. For example int, double, true, and import are ______.

28
New cards

expression

n is a combination of constants (like 100), operators ( like +), variables(section of memory) and parentheses ( like “(” and “)” ) used to calculate a value.

29
New cards

arithmetic operator

r is a symbol that asks for doing some arithmetic.

30
New cards

CONCATENATION

Refers to the operation of joining two strings together. You can join strings using either the addition (+) operator or the String's concat() method

31
New cards

PARENTHESES

Difference between -1 ( 9 - 2 ) 3 - 2 3 and -1 9

To say exactly what numbers go with each operator, use _______

32
New cards

Nested Parentheses

The expression is evaluated starting at the most deeply nested set of parentheses (the "innermost set"), and then working outward until there are no parentheses left.

If there are several sets of parentheses at the same level, they are evaluated left to right.

33
New cards

SCANNER

■ The Scanner class of the java.util package is used to read input data from different sources like input streams, files, etc.

■ The Java Scanner class is widely used to parse text for strings and primitive types using a regular expression.

■ It is the simplest way to get input in Java.

34
New cards

SCANNER

■ It is the simplest way to get input in Java.

35
New cards

Output Import Scanner Class

■ Import the java.util.Scanner package before we can use the Scanner class.

36
New cards

The Scanner class provides various methods that allow us to read inputs of different type

Java Scanner nextInt() Java Scanner nextDouble() Java Scanner next() Java Scanner nextLine()

37
New cards

next()

Reads the next single word (stops at space).

38
New cards

nextLine()

reads the entire line of text (including spaces until Enter is pressed).

39
New cards

nextDouble()

Reads the next input as a decimal number (floating-point).

40
New cards

nextInt()

Reads the next input as an integer (whole number).

41
New cards

Strings

are a fundamental data type that represent sequences of characters.

42
New cards

The String class

is used to create and manipulate strings.

43
New cards

immutable

Strings in Java are ______ meaning once a string object is created, it cannot be modified.

44
New cards

new string object

Any operation that appears to modify a string actually creates a what

45
New cards

double quotes

 String literals in Java are enclosed in .

46
New cards

JVM (Java Virtual Machine)

When a string literal is used, the ____checks the string pool to see if the string already exists.

47
New cards

string literal is used → JVM checks the string pool

 If it does, the existing string is reused; otherwise, a new string is added to the pool. This optimization reduces memory overhead.

48
New cards

object (java)

An ______t is any entity that has a state and behavior. For example, a bicycle is an object.

 States: idle, first gear, etc

 Behaviors: braking, accelerating, etc.

49
New cards

Class (java)

is a blueprint for the object. Before we create an object, we first need to define the ______

50
New cards

Class (java)

 We can think of the class as a sketch (prototype) of a house. It contains all the details about the floors, doors, windows, etc. Based on these descriptions we build the house. House is the object.

51
New cards

length()

: Returns the length of the string. String str = "Hello"; int length = str.length();

52
New cards

charAt(int index)

Returns the character at the specified index. char ch = str.charAt(1);

53
New cards

substring(int beginIndex, int endIndex)

Returns a new string that is a substring of the original string. String sub = str.substring(1, 4);

54
New cards

concat(String str)

Concatenates the specified string to the end of the current string. String greeting = "Hello".concat(", World!");

55
New cards

indexOf(String str)

Returns the index within the string of the first occurrence of the specified substring. int index = str.indexOf("e");

56
New cards

toUpperCase() and toLowerCase()

Convert the string to uppercase or lowercase.

String upper = str.toUpperCase(); String lower = str.toLowerCase();

57
New cards

trim()

: Removes whitespace from both ends of the string. String spaced = " Hello "; String trimmed = spaced.trim();

58
New cards

Control flow statements

in programming control the order in which the computer executes statements in a file. They allow us to regulate the flow of our program's execution.

59
New cards

• Decision-Making Statement

• Loop Statements

• Jump Statements

TYPES OF CONTROL FLOW STATEMENTS IN JAVA

60
New cards

DECISION-MAKING STATEMENT

Assist in making decisions. It decides which statement to execute and when. Java provides the facility to make decisions using selection statements or selection constructs

61
New cards

• if Statement • switch Statement

Java provides two types of decision-making statements:

62
New cards

Selection

is a decision-making process. The outcome of a decision determines which process the system takes.

63
New cards

"If" Statement

is the simplest decision-making statement.

64
New cards

"If" Statement

It is used to decide whether a block of code should be executed or not based on the test condition.

65
New cards

"If" Statement

f the condition is evaluated to true, then that block is executed; otherwise, it is skipped.

66
New cards

"If-Else"

is an extension of the If-statement.

67
New cards

if statement

only tells what to do if the condition evaluates to true.

It does not tell anything when the condition is false

68
New cards

If-Else

provides the provision of an else block, which is executed when the condition is false. It has a provision to accommodate one more block of code.

69
New cards

"If-Else-If" LADDER

consists of an if statement followed by multiple else-if statements. It is used to evaluate a condition using multiple statements. The chain of if statements are executed from the top-down. 30;

70
New cards

NESTED-IF

contains an if statement inside another if statement. Java allows us to nest if equations with another if or an else if statement.

71
New cards

SWITCH STATEMENT

in java is used to execute a single statement from multiple conditions. The switch statement can be used with short, byte, int, long, enum types, etc.

Case values that are duplicate are not permissible

72
New cards

SWITCH STATEMENT

• Usage of break statement is made to terminate the statement sequence. It is optional to use this statement. If this statement is not specified, the next case is executed.

73
New cards

LOOPING STATEMENTS

Statements that execute a block of code repeatedly until a specified condition is met are known as looping statements.

74
New cards

• 1. While • 2. Do-While • 3. For • 4. For-Each

Java provides the user with three types of loops:

75
New cards

WHILE

• Known as the most common loop, the while loop evaluates a certain condition. If the condition is true, the code is executed. This process is continued until the specified condition turns out to be false. • The condition to be specified in the while loop must be a Boolean expression. An error will be generated if the type used is int or a string.

76
New cards

DO-WHILE

• The do-while loop is similar to the while loop, the only difference being that the condition in the do-while loop is evaluated after the execution of the loop body. This guarantees that the loop is executed at least once.

77
New cards

FOR LOOP

• The for loop in java is used to iterate and evaluate a code multiple times. When the number of iterations is known by the user, it is recommended to use the for loop

78
New cards

FOR-EACH

• The traversal of elements in an array can be done by the for-each loop. The elements present in the array are returned one by one. It must be noted that the user does not have to increment the value in the for-each loop.

79
New cards

BREAK

The ______ statement in java is used to terminate a loop and break the current flow of the program

80
New cards

CONTINUE

• To jump to the next iteration of the loop, we make use of the _______ statement.

81
New cards

CONTINUE

This statement continues the current flow of the program and skips a part of the code at the specified condition

82
New cards

Pseudocode

s an artificial and informal language that helps programmers develop algorithms.

is very similar to everyday English.

83
New cards

Flowchart (Dictionary)

A schematic representation of a sequence of operations, as in a manufacturing process or computer program.

84
New cards

Flowchart (Technical)

A graphical representation of the sequence of operations in an information system or program.

85
New cards

Information system

show how data flows from source documents through the computer to final distribution to users.

86
New cards

Program flowcharts

show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart.

87
New cards

A Flowchart

• shows logic of an algorithm

emphasizes individual steps and their interconnections

• e.g. control flow from one action to the next

88
New cards

Oval

Denotes the beginning or end of the program

89
New cards

Parallelogram

Denotes an input operation

90
New cards

Rectangle

Denotes a process to be carried out e.g. addition, subtraction, division etc.

91
New cards

Diamond

Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE

92
New cards

Hybrid

Denotes an output operation

93
New cards

Flow line

Denotes the direction of logic flow in the program

94
New cards

Flowcharts

s is a graph used to depict or show a step by step solution using symbols which represent a task.

95
New cards

Flowcharts

The symbols used consist of geometrical shapes that are connected by flow lines

96
New cards

Flowcharts

It is an alternative to pseudocoding; whereas a pseudocode description is verbal, a flowchart is graphical in nature.

97
New cards

Terminal symbo

indicates the beginning and end points of an algorithm.

98
New cards

Process symbol

shows an instruction other than input, output or selection.

99
New cards

Input-output symbol

- shows an input or an output operation.

100
New cards

Disk storage I/O symbol

indicates input from or output to disk storage.