Section 1

Preview this deck

do while loop syntax

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (100)

Section 1

(50 cards)

do while loop syntax

Front

do { // Loop body; Statement(s); } while (loop-continuation-condition);

Back

(x % n == 0)

Front

number x is divisible by n

Back

main method

Front

method called by JVM to start a program

Back

conditional expression syntax

Front

boolean-expression ? expression1 : expression2; The result of this conditional expression is expression1 if boolean-expression is true; otherwise the result is expression2.

Back

comparison operator

Front

=relational op., mathematical operators to compare:

Back

loop

Front

a programming construct that repeats a group of commands.

Back

pretest loops

Front

check before the action (for and while loops); they may never act

Back

for loop syntax

Front

for (initial-action; loop-continuation-condition; action-after-each-iteration) { // Loop body; Statement(s); } (If the loop-continuation-condition in a for loop is omitted, it is implicitly true, therefore infinite- while loop would be more efficient)

Back

else if

Front

used to simplify multiple nested alternatives

Back

Main Method Syntax

Front

Public static void main(String[] args) { // code }

Back

continue statement

Front

breaks up the current iteration of a loop if a certain condition is fulfilled, use it to e.g. exclude certain cases from being included from the execution of a for loop body

Back

(formal) parameters

Front

variables defined in the method header (need to be defined separately)

Back

do-while loop

Front

like while loop, but executes the loop body before checking the continuation condition (use when statements must appear at least once before the loop kicks in)

Back

goto statement

Front

a statement that transfers control to some other statement, which is tagged with a label. Java does not have a goto statement.

Back

actual parameter (argument)

Front

value associated with the parameter when method is invoked

Back

ambiguous invocation

Front

If the compiler finds two or more methods that equally match a given call, it will issue an error

Back

sentinel value

Front

a preselected value that stops the execution of a program (doesn't work with floating point values)*

Back

posttest loop

Front

a loop whose condition is evaluated after the instructions in its loop body are processed

Back

conditional expression

Front

way to assign a value to a variable under a certain condition

Back

method overloading

Front

When multiple methods have the same name, but different parameters. (preferred method style since it makes program more readable and clearer)

Back

class

Front

A class is a template, blue- print, or contract that defines what an object's data fields and methods will be, one class can have multiple objects

Back

value-returning method

Front

A method that returns a value(, it's body requires a return statement)

Back

local variable

Front

a variable that is declared within a method, must be given a value before it's used and can't be used outside that method(=block of code) e.g. a parameter (can't be declared twice)

Back

object

Front

represents an entity in the real world that can be distinctly identified e.g. a circle through its: 1.state=data fields (defined by variables) e.g. radius 2.behavior=methods e.g. getPerimeter() also known as an instance of a class

Back

pass-by-value

Front

Passing the value of an argument to a method. The type of data passed depends on whether the argument is a primitive or an object. (memory allocation for argument and parameter is independent)

Back

modularizing code

Front

making it more efficient*

Back

graphical user interface (=GUI)

Front

Back

%

Front

modulus operator; divides two integers and returns the remainder as an integer

Back

invoking a method from another class (in the package)

Front

call: className.methodName

Back

method syntax

Front

modifier returnValueType methodName (parameters){ body= statements }

Back

method abstraction

Front

Achieved by separating the use of a method from its implementation, where method body=black box aka. hidden from user

Back

switch statement syntax?

Front

switch ([control expression]) { case [integer type (char works) that may be equal to control expression]: [Stuff to do with control expression varable]; break; default: [stuff to do if none of the cases equal the control] } *you can also stack cases example: switch(letter) { case 'a': case 'e': case 'i': case 'o': case 'u': isVowel = true; break; default : isVowel = false; break: }

Back

method signature

Front

The name of a method, along with its number and type of parameters, it's used to invoke a method

Back

while loop

Front

construct used to repeat a set of commands (loop) as long as (while) a boolean condition is true (braces enclosing the loop body can be omitted only if the loop body contains one or no statement.) (used for infinity loops or true or false boolean condtions)

Back

for loop

Front

standard loop, used if the number of desired iterations is known

Back

parameter order association

Front

arguments must be given in the same order as the formal parameters to call method correctly

Back

Calling a Value-Returning Method

Front

call is treated as a value, either in print statement or in the declaration of a variable

Back

selection statement

Front

=conditional statement, .allows us to choose which statement will be executed next based on the evaluation of a boolean condition. e.g. if, if...else, else...

Back

switch statement

Front

allows multi-way branching. In many cases, using a switch statement can simplify a complex combination of if-else statements.

Back

Boolean data type

Front

allows you to create variables that may hold one of two possible values: "true" or "false"

Back

if-else statement

Front

allows your program to perform one action if the Boolean expression evaluates to true and a different action if the Boolean expression evaluates to false, therefore if statement that always operates

Back

End-of-line Block Style

Front

starting the braces right after the parameter list of a method instead of in the next line

Back

counter-controlled loop

Front

a loop whose processing is controlled by a counter; the loop body will be processed a precise number of times

Back

if statement

Front

A statement that determines whether or not you run a certain chunk of code, and therefore allows for alternate paths of execution

Back

while loop syntax

Front

while (condition)//initialise a counter variable before the loop { statement(s);//one of the statements must be an increment otherwise loop is infinite }

Back

constructor

Front

a method mainly for creating objects (using the new operator), by initializing their variables

Back

break statement

Front

A statement that terminates a loop or switch statement.

Back

Calling void methods

Front

call requires a statement*

Back

Method

Front

series of statements grouped together to perform an operation, way to make code reusable

Back

void method

Front

A method with void in place of the return type, which does not return a value when called

Back

Section 2

(50 cards)

package-private (or package-access)

Front

without visibility modifier classes, methods, and data fields are accessible by any class in the same package

Back

static method

Front

methods that belong to a class, that can be called without creating an object, can only utilize static variable and, can be accessed from a reference variable or from their class name e.g. ClassName.methodName(arguments)

Back

scope of none local variables

Front

static and instance variables can be declared only once and are valid throughout the whole class no matter where they are declared within it, if a local variable has the same name the class variable remains hidden within that method

Back

size of an array

Front

arrayRefVar.length

Back

data field called via reference variable

Front

=instance variable, since it's dependent on the instance it's called with e.g. radius (of a circle)

Back

ArrayList class

Front

Manages a sequence of objects like array of objects but is here the number of objects is unlimited

Back

indexed variable

Front

way to access array element: arrayRefVar[index];

Back

array

Front

collection of variables of the same type

Back

Array Declaration syntax

Front

elementType[] arrayRefVar; , does not allocate any space in memory for the array only for its reference variable

Back

for each loop syntax

Front

for (elementType element: arrayRefVar) { // Process the element } or: arrayList: for (elementType variable: arrayListRefVar) { // Process the element }

Back

instantiation

Front

Process of creating an object, an instance of a class; creates space in memory for the new object and binds a name for the object with the object's data in memory.

Back

one-dimensional array

Front

an array in which each data item is accessed by specifying a single index

Back

data structure

Front

collection of data organized in some fashion also supports operations for accessing and manipulating the data e.g. arrayLists (if they hold objects, also known as container or container object)

Back

Initializing arrays with random values

Front

1.declare and create an array for(int m=0;m<arrayReferenceVar.length;m++){ arrayReferenceVar[m]= Math.random()*100; }

Back

reference variable

Front

Stores (points to) the memory address of an object, can be used to access the methods/variables of the class for a particular object through dot operator: objectReferenceVariable.ClassMethod(argument) or referenceVariable.variable

Back

Unified Modeling Language (UML)

Front

A language based on object-oriented concepts that provides tools such as diagrams and symbols to graphically model a system.

Back

Immutable Class

Front

A class with solely private data fields and without a mutator method or an accessor that passes value to a mutable data field

Back

Array of Objects

Front

=array of reference variables

Back

Math.PI

Front

constant from math class that represents pi

Back

method called via reference variable

Front

=instance method, instance on which the method is invoked = calling object

Back

immutable object

Front

An object whose value cannot be changed.

Back

Initializing arrays with input values

Front

1.declare and create an array java.util.Scanner input= new java.util.Scanner(System.in); System.out.println("Enter "+arrayReferenceVar+" new values: "); for(int m=0;m<arrayReferenceVar.length;m++){ arrayReferenceVar[m]=input.nextDouble(); }

Back

Constants

Front

shared by all objects of the class, thus declared as final static.

Back

array initializer

Front

A shorthand notation to, declare, create and initialize an array: elementType[] arrayRefVar = {value0, value1, ..., valuek}; (only works like this, no new operator)

Back

for-each loop

Front

a loop that allows you to go through each element one by one without using the index

Back

default constructor

Front

A no-argument constructor without a body, automatically provided by Java for classes that do not have any constructors

Back

Array creation syntax

Front

arrayRefVar = new elementType[arraySize]; * Array declaration and creation can be combined: elementType[] arrayRefVar = new elementType[arraySize];

Back

format specifier

Front

A special code that begins with a percent sign and specifies the data type and format of the corresponding value.

Back

visibility modifier

Front

public, private, or protected. A modifier used to denote which portions of the system should be able to see a variable or a method

Back

Constructor syntax

Front

access specifier(PUBLIC) name of class (list of parameters including data type) { constructor body; }

Back

static variable

Front

shared by all objects of the class, change its value and value is changed in all objects using it since it's stored in a common memory space accessed by: ClassName.staticVariable

Back

summing up array values

Front

double sum=0.0; for(int m=0;m<arrayRefVar;m++){ sum+=arrayRefVar[m]; } System.out.println("the sum is: "+sum);

Back

private modifier

Front

specifies that the member can only be accessed in its own class, using the modifier=encapsulating

Back

client of class

Front

class that uses class in question e.g. main

Back

equals method

Front

method from the object class that's been overridden in several of it's subclasses, you can override it too

Back

for each loop syntax

Front

for (elementType element: arrayRefVar) { // Process the element } or: arrayList: for (elementType element: arrayList) { // Process the element }

Back

pass-by-sharing

Front

pass-by-value for references*

Back

toString method syntax

Front

public String toString(){ return //override of default output; }

Back

Inheritance

Front

enables you to define a general class (i.e., a superclass) and later extend it to more specialized classes (i.e., subclasses). Private data fields in a superclass are not accessible outside the class. Therefore, they cannot be used directly in a subclass. They can, however, be accessed/mutated through public accessors/mutators if defined in the superclass. Contrary to the conventional interpretation, a subclass is not a subset of its superclass. In fact, a subclass usually contains more information and methods than its superclass.

Back

public visibility modifier

Front

for classes, methods, and data fields that should be allowed to be accessed from any other class

Back

visibility modifiers for classes

Front

not defined=class can be only accessed within the same package public= unrestricted access

Back

element type

Front

The type of data that an array is declared to hold

Back

overriding

Front

means to provide a new implementation for a method in the subclass

Back

ArrayList syntax

Front

ArrayList<AConcreteType> list = new ArrayList<AConcreteType>(); or simplified:ArrayList<AConcreteType> list = new ArrayList<>();

Back

toString method

Front

converts any object to a String and is therefore a quick and simple way to display all elements in the array

Back

Java Collections Framework

Front

data structures that can be used to organize and manipulate data efficiently includes 2 types of containers: 1.collections 2.maps

Back

this keyword

Front

Within an instance method or a constructor, this is a reference to the current object — the object whose method or constructor is being called. You can refer to any member of the current object from within an instance method or a constructor by using this (it is usually omitted). doesn't apply to static variables (there: ClassName.staticVariable) used inside a setter to create object since the variable is still hidden inside its parameter list or used to invoke another constructor*

Back

anonymous object

Front

object that's created without a reference variable assigned to it, since there's no need to refer to it later

Back

Displaying arrays

Front

1.declare, create an array and populate an array for(int m=0;m<arrayRefVar.length;m++){ System.out.print(arrayRefVar[m]+" ");

Back

data field encapsulation

Front

declare the data fields private to prevent direct modification

Back