Java CSA Semester 1

Ace your homework & exams now with Quizwiz!

logical and

&&

What will be printed by System.out.println(Integer.MAX_VALUE + 1);?

-2147483648

What does the following code print? System.out.println(1 / 3);

0

Which of the following would be the correct result from the following expression: 123 (decimal) - 12 (octal) + 111 (binary)?

120

What does the following code print? System.out.println(2 + 3 * 5 - 1);

16

What does the following code print? System.out.println(2 % 3);

2

What does the following code print? System.out.println(19 % 5);

4

Given the following code segment, what is the value of b when it finishes executing? double a = 9.6982; int b = 12; b = (int) a;

9

complex conditional

A Boolean expression with two or more conditions joined by a logical and '&&' or a logical or '||'.

Java

A Programming language that you can use to tell a computer what to do.

child class

A class that inherits the characteristics of a parent class.

Nested Loop

A loop inside the body of another loop.

Out of Bounds error

A run-time error that occurs when you try to access past the end of a string or list in a loop.

string

A sequence of characters

Syntax Error

A syntax error is an error in the specification of the program.

Array Index

A value that indicates the position in the array of a particular value. The last element in a zero-indexed array would be the length of the array, minus 1.

Array

An array can hold many items (elements) of the same type. You can access an item (element) at an index and set an item (element) at an index.

Compile time error

An error that is found during the compilation. These are also called syntax errors.

new

Creates an object from an existing class.

ere is a method called checkString that determines whether a string is the same forwards and backwards. The following data sets can be used for testing the method. What advantage does Data Set 2 have over Data Set 1? Data Set 1 Data Set 2 aba bcb abba bcd aBa

Data Set 2 contains one string which should return true and one that should return false.

Class

Defines a type.

Object

Does the actual work in an object-oriented program.

What is the value of s1 after the following code executes? String s1 = "Hey"; String s2 = s1.substring(0,1); String s3 = s2.toLowerCase();

Hey

What does the follow code do when it is executed? System.out.println(5 / 0);

It will give a compile-time error (won't compile)

immutable

Strings cannot be changed

parent class

The class from which a child class inherits.

short circuit evaluation

The type of evaluation used for logical and '&&' and logical or '||' expressions. If the first condition is false in a complex conditional with a logical and the second condition won't be evaluated. If the first condition is true is a complex conditional with a logical or the second condition won't be evaluated.

Compiler

Translates a Java source file (ends in .java) into a Java class file (ends in .class).

Main Method

Where execution starts.

Trace Code

Writing down the values of the variables and how they change each time the body of the loop executes.

substring

a portion of a string

Given the following code segment, what is the value of num when it finishes executing? double value = Math.random(); int num = (int) (value * 11) - 5;

a random number from -5 to 5

Given the following code segment, what is the value of num when it finishes executing? double value = Math.random(); int num = (int) (value * 5) + 5;

a random number from 5 to 9

Private

a visibility keyword which is used to control the classes that have access. The keyword private means that only the code in the current class has direct access.

Public

a visibility keyword which is used to control the classes that have access. The keyword public means the code in any class has direct access.

Boolean expression

an expression that evaluates to True or False.

conditional

an if-then statement

Method

defines behavior.

immutable

doesn't change

For Loop

for(int i; i =< 10;i++){ //loop code }

length

gets the length of string

Field

holds data or a property.

Constructor

initializes the fields of an object after it has been created.

Array Declaration

int[] nums= new int[5];

For Each Loop

int[] test = {1,6,4,7,9,9,5,32,2,6,7} for(test){ //code to execute }

Given the following code are the contents of itemArray and val after a call of mod(itemArray,val)? int[] itemArray = {9, 8, 7, 6}; int val = 5; public static void mod(int[] a, int value) { for (int i=0; i < a.length; i++) { a[i] = i; } value = a[a.length-1]; }

itemArray = {0, 1, 2, 3} and val = 5;

concatenate

link together

DeMorgan's Laws

not (a and b) is the same as (not a) or (not b) not (a or b) is the same as (not a) and (not b)

null

not yet initialized

What is output from the following code? String s = "Georgia Tech"; String s1 = s.substring(0,7); String s2 = s1.substring(2); String s3 = s2.substring(0,3); System.out.println(s3);

org

What does the following code print? System.out.println("13" + 5 + 3);

prints 1353

append

to attach to another string

override

to take priority over the parent class

Given the following code segment, what is in the string referenced by s1? String s1 = "xy"; String s2 = s1; s1 = s1 + s2 + "z";

xyxyz

logical or

||


Related study sets

Review: Principles of Ecology - Food Chains

View Set

Prep U Porth chapter 26 blow flow & pressure

View Set

Chapter 15, Section 1: Two Revolutions in Russia

View Set

Exam 2 Pharmacology for Nurses (13, 48-50, 44-47, 39-40)

View Set

Microeconomics - midterm 3 multiple choice

View Set

GCSE psychology quiz on prejudice and discrimination

View Set

Understanding Economics Chapter 11 Questions

View Set