Fichas
OOP MIDTERM EXAM

Fichas del conjunto (35)
- 1________types are used to store simple values/dataPRIMITIVE DATA TYPES
- 2Any instantiable class as well as arrays: String, Scanner, Random, Die, int[], String[], etc. Reference variables store addresses to locations in memory for where the data is stored. Also known as Wrapper classesREFERENCE DATA TYPES
- 3are declared in methods, constructors, or blocks.LOCAL VARIABLES
- 4are declared in a class, but outside a method, constructor or any blockINSTANCES VARIABLE
- 5are declared with the static keyword in a class, but outside a method, constructor or a block.STATIC VARIABLE
- 6ELSE STATEMENT SYNTAX:if (condition) {
// block of code to be executed if the condition is true
} else {
// block of code to be executed if the condition is false
} - 7variable = (condition) ? expressionTrue : expressionFalse;Short Hand If...Else
(Ternary Operator) - 8a computer program is an instruction that repeats until a specified condition is reached.LOOP
- 9uses a loop control variable in the logical expression. The loop control variable should be initialized before entering the while loop, and a statement in the body of the while loop should increment/decrement the control variableCOUNT CONTROLLED LOOP
- 10use a special data value, called ________, in conjunction with the logical expression to signal the loop exit. As long as the sentinel value does not meet the logical expression (specified data value), the loop is executed.SENTINEL-CONTROLLED LOOP
- 11It uses Boolean variable called a _____ which is a boolean variable (only can be set to true or false). used in a while loop to control the loop executionFLAG-CONTROLLED LOOP
- 12is often used to repeatedly read data. When a program uses a stream to read data, the stream state is set after each read from the input data stream.END OF FILE-CONTROLLED LOOP
- 13Why Repetition is needed-EFFECTIVE
-EFFICIENT
-ROBUST/HEALTHY
-SHORTER/LESS-CODES
-AVOID REDUNDANT STATEMENTS - 14for(initial expression; logical expression; update expression) { //statement(s) } for(i = 0; i < 5; i++) { // block of code }FOR-LOOP
– Initial statement executes
– The loop condition is evaluated
– If loop condition evaluates to true, execute for loop statement
and execute update statement
– Repeat until loop condition is false - 15while(boolean condition) { //statements; }WHILE LOOP
- 16do { // Code block to be executed } while (condition);DO-WHILE LOOP
- 17Nested Control Structures Example for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) System.out.print(" *"); System.out.println(); }OUTPUT
*
**
***
****
***** - 18ArrayList provides convenient methods to manipulate the array's size, add or remove elements, and perform other operations. This flexibility makes dynamic arrays a powerful tool in situations where the number of elements is not known in advance or may change dynamically.What are the new things
that you have discovered
in array concepts? - 19How do you apply arrays to your program? Cite an example program you think it can be appliedStudent Grade Calculator:
An array can be used to store the grades of a group of students in a class. By using an array, the program can efficiently store and manipulate the grades of each student. It can calculate statistics such as the average grade, highest grade, lowest grade, or even perform operations like grade sorting. The array allows easy access to individual grades and enables the program to perform calculations or generate reports based on the data. - 20Are there any things you still don’t understand in array? What are these and what is/are the reasons?Indexing: One common challenge is understanding how array indexing works. Arrays in many programming languages use zero-based indexing, meaning the first element is accessed using index 0. This indexing convention can be confusing for newcomers, leading to off-by-one errors or incorrect array access.
- 21—The value of the code is 90

- 22—The code is error because the correct index value is must be = 0
so that it gets its total = 309
- 23How does methods important in java?It is essential and play a crucial role because methods are block of code that perform specific task and are design to promote code reuse, modularity, and maintainability
- 24is a block of code which only runs when it is called. You can pass data, known as parameters, into a _____. _______are used to perform certain actions, and they are also known as functions. ⮚Reuse code ⮚Define the code once ⮚Use it many timesMETHODS
- 25THERE ARE TWO TYPES OF METHODS WHAT ARE THOSE?PRE-DEFINED METHOD
&
USER-DEFINED METHOD - 26Is a method that is created by the programmer to perform a specific task or set of operations.USER-DEFINED METHOD
To create a user-defined method in Java, you need to
follow these basic steps:
▪ Method Declaration
▪ Method Body
▪ Method Invocation - 27are methods that are provided by the Java programming language itself. These methods are part of the Java API (Application Programming Interface) and are included in the standard Java libraries.PRE-DEFINED METHOD
▪ Math class methods
▪ String class methods
▪ Array class methods
▪ File handling methods - 28The User-defined Method SYNTAX:modifier return-type method-name parameter-list {
//body of the method
} - 29User-defined Method Types of Modifiers in JAVA:➢ Access Modifiers
- public, private, protected
➢ Non-Access Modifiers
- static, final, abstract, synchronized,
volatile, native - 30methods declarations have 6 components:- Modifier
-The Return Type
- Method Name
- Parameter list
- Exception List
- Method Body - 31There are Five User-Defined Method Declaration of The return type:Example:
- void
- int
- double
- String
- boolean - 32—


- 33It is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched. • Start from the leftmost element of arr[] and one by one compare x with each element of arr[] • If x matches with an element, return the index. • If x doesn’t match with any of elements, return -1LINEAR SELECTION
- 34—TAMA NA CODE

- 35—


Información
- Descripción
- Fichas sobre OOP MIDTERM EXAM, creado por Eddieblair June Villar el 14/05/2023.
- Creado por
- Eddieblair June Villar
- Visitas
- 1
- Valoración