Data Structures and algorithms with java - chapter 1

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/41

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.

42 Terms

1
New cards

The java interpreter is known as the ______________________

Virtual Machine

2
New cards

javac is the ___________________

local compiler

3
New cards

Java ___________________ represent the portable intermediate

language that is interpreted by running the Java interpreter

bytecodes

4
New cards

Java defines __ primitive types

8

5
New cards

Java's primitive integral data types are __________________

int, byte,short and long

6
New cards

Floating-point numbers are represented by the types __________ and _________________

float, double

7
New cards

_______________ has more significant digits, so use of it is recommended

over use of ___________________________

double, float

8
New cards

The __________ type is used to represent single characters, it occupies _____________ bits to represent the unicode standard

char, 16

9
New cards

What is the range of a byte data type and what does it store?

-128 to 127, 8 bit integer

10
New cards

What is the range of a short data type and what does it store?

-32,768 to 32,767, 16 bit integer

11
New cards

What is the range of an int data type and what does it store?

-2,147,483,648 to 2,147,483,647, 32 bit integer

12
New cards

What is the range of a long data type and what does it store?

-2^63 to 2^63 - 1, 64 bit integer

13
New cards

What is the range of a float data type and what does it store?

6 significant digits ( 10-46, 1038 ), 32 bit floating point

14
New cards

What is the range of a double data type and what does it store?

15 significant digits ( 10-324, 10308 ),

15
New cards

Which data type holds a value that is either true or false?

Boolean

16
New cards

The assignment operator is the _________________ ___________________

equals sign

17
New cards

What does the "+=" sign achieve

The += sign is an assignment operator that adds the value on its right-hand side to the variable on the left-hand side

18
New cards

What are other assignment operators?

-=, *=, /=

19
New cards

What are the binary arithmetic operators?

-, / ,* , %

20
New cards

What are the unary operators?

++ and --

21
New cards

Java's logical operators are______________,_______________,________________ and are used to simulate boolean algebra. They are sometimes known as ______________,_______________,________________

AND, OR, NOT, conjunction, disjunction, negation

22
New cards

Which logical operator takes highest precedence and which takes the lowest?

! (negation) has the highest precedence while || (or) has the lowest precedence.

23
New cards

What does it mean for a logical operator to be a short-circuit evaluation and which operators are short-circuit?

Short-circuit evaluation means that if the result can be determined by examining

the first expression, then the second expression is not evaluated.

24
New cards

The three basic forms of looping in Java are __________________, __________________, ___________________

for, do, and while

25
New cards

What is the break statement?

the break statement exits the innermost loop only. It is used in conjunction with loops and the switch statement for termination often times before the

26
New cards

What does the continue statement do?

The continue statement goes to the next iteration of the innermost loop. It is commonly used to avoid complex if-else patterns inside loops

27
New cards

What symbol is used for the conditional operator?

The question(?) mark in the following form x<=y ? x : y;

28
New cards

What is known as a function or procedure in other programming languages is known as a ___________________ in java.

method

29
New cards

The parameter list consist of zero or more of these ?

Formal parameters

30
New cards

When a method is called , the __________________ are sent into the formal parameters using normal assignment.

actual arguments

31
New cards

Java allows the _______________ of method names.

overloading - This means that several

methods may have the same name and be declared in the same class scope as

long as their signatures (that is, their parameter list types) differ.

32
New cards

static final variables are _____________________

constants

33
New cards

What extensions are used for java source and compiled files?

.java for java source files, and .class for compiled files.

34
New cards

Describe the three kinds of comments used in Java programs.

// which is for single line comments. / -- / which is for multiline comments. and /** which generates documentation from its comments.

35
New cards

What are the eight primitive types in java?

byte, long, boolean, int, double, float, char, String

36
New cards

What is the difference between the and = operators?

* is a binary operator.

*= is an assignment operator.

37
New cards

Explain the difference between the prefix and postfix increment

operators.

The prefix increment will increment the value immediately, while the postfix operator will increment the value the next time it is called.

38
New cards

Describe the three types of loops in Java

There are three loops in java, do..while, while, and for. The for loop is sufficient to express all repetition, the do...while loop always executes at least once, the while loop on the other hand will only increment if the statement evaluates to true.

39
New cards

Describe all the uses of a break statement. What is a labeled break

statement?

The break statement allows exit from the innermost loop. If there are several

loops that need exiting, the break will not work, and most likely you have poorly

designed code.

The break statement is often used in the switch statement.

40
New cards

What is a labeled break

statement?

a loop is labeled, and then a break statement can be applied to the

loop, regardless of how many other loops are nested

outer:

while( ... )

{

while( ... )

if( disaster )

break outer; // Go to after outer

}

// Control passes here after outer loop is exited

41
New cards

What does the continue statement do?

Occasionally, we want to give up on the current iteration of a loop and go

on to the next iteration. This can be handled by using a continue statement.

The following fragment prints the first 100

integers, with the exception of those divisible by 10:

for( int i = 1; i <= 100; i++ )

{

if( i % 10 == 0 )

continue;

System.out.println( i );

}

Of

42
New cards

What is method overloading?

is the allowance of multiple methods of the same name in the same class as long as their parameter lists differ.