Comp Sci Test 1

studied byStudied by 9 people
5.0(1)
Get a hint
Hint

Why do we use Java?

1 / 52

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

53 Terms

1

Why do we use Java?

Java is object oriented — models the real world, greater flexibility, modularity, and reusability

New cards
2

What do object oriented languages allow for?

inheritance

New cards
3

what is an object

a specific concrete representation of a class

New cards
4

what is instantiation

the creation of an instance/object from a class; creating a concrete representation of a class (aka initialization)

New cards
5

What are the types of programs in java?

  1. Standalones

    • does not need internet browser

    • needs a main method

  2. Applets

    • does not need main method

    • can be executed through a network browser and use a GUI class library

New cards
6

What are the naming conventions for a class?

Every first letter of the word must be capitalized (e.g. HelloWorld)

New cards
7

what is the process of java?

storage, input, process, output

New cards
8

What are the primitive data types?

boolean (1 bit)

char (16 bits)

byte (8 bits)

short (16 bits)

int (32 bits)

long (64 bits)

float (32 bits)

double (64 bits)

New cards
9

what is the function and size of boolean

true or false; 1 bit

New cards
10

what is the size of char?

16 bits

New cards
11

what is the function and size of byte?

integer; 8 bits

New cards
12

what is the function and size of short?

integer; 16 bits

New cards
13

what is the function and size of int?

integer; 32 bits

New cards
14

what is the function and size of long?

integer; 64 bits

New cards
15

what is the function and size of float?

decimal; 32 bits

New cards
16

what is the function and size of double?

decimal; 64 bits

New cards
17

what are the naming conventions for variables?

Capitalize first letter of every word except for the first word (e.g. startingNumber)

New cards
18

what are the naming conventions for methods?

Capitalize first letter of every word except for the first word (same as variables)

New cards
19

what are the naming conventions for constants?

the word “final”(lowercase) followed by the type, followed bu the name of the constant in all caps (e.g. final double PI =3.14)

New cards
20

why are constants important?

  • it minimizes memory

  • makes things more efficient/run faster by optimizing memory

  • think: video games

New cards
21

what is casting?

casting means explicitly telling Java to make a conversion

New cards
22

when is casting required?

when you want to perform a narrowing conversion

New cards
23

what is important to know about a narrowing conversion?

narrowing runs the risk of losing information

New cards
24

what are the 2 rules for casting of primitive data types?

  1. you may cast any non-boolean type to any other non-boolean type

  2. you may NOT cast a boolean type to any other type or vice versa

New cards
25

what are the three types of loops common to any programming language?

counted loops, conditional loops, and infinite loops

New cards
26

what are the three types of loops in Java?

for loops, while loops, and do while loops

New cards
27

when should you use a counted loops?

when you know how many times you want something to loop

New cards
28

when should you use conditional loops?

when you don’t know how many times you want something to loop

New cards
29

what is the difference between a while loop and a do while loop?

while loops give the user an option to enter the loop or not (condition occurs at the beginning of the loop), and do while loops force the user to enter the loop at least once (condition occurs at the end of the loop)

New cards
30

what are the parts of a for loop?

initialization, test/exit condition, increment/decrement

New cards
31

what is the symbol for less than?

<

New cards
32

what is the symbol for less than or equal to?

<=

New cards
33

what is the symbol for greater than?

New cards
34

what is the symbol for greater than or equal to?

=

New cards
35

what is the equality operator symbol for equals?

==

New cards
36

what is the symbol for not equal?

!=

New cards
37

what is the logical operator symbol for “and”?

&&

New cards
38

what is the logical operator symbol for “or”?

||

New cards
39

what is the difference between = and ==

“=” is used to assign value, and “==” is a relational operator for comparing

New cards
40

what does x+=y mean?

x=x+y

New cards
41

what does x-=y mean?

x=x-y

New cards
42

what does x*=y mean?

x=x*y

New cards
43

what does x/=y mean?

x=x/y

New cards
44

what does y=x++ mean?

y=x+1 (x is incremented after)

New cards
45

what does y=++x mean?

y=x+1 (x is incremented before)

New cards
46

what is selection?

a method used to make choices based on conditions

New cards
47

what is switch case selection used for?

it’s useful for things like menu selection where each choice/outcome is associated with an integer value

New cards
48

what are the limitations of switch case?

  • the expression of a switch statement must be int or char (integral type)

    • it can’t be boolean or any other type

  • switch case cannot perform relational checks

New cards
49

what are the parts of the software design process?

  1. problem definition

  2. list of identifiers/analysis

  3. algorithm/design

  4. coding/implementation

  5. testing and debugging

  6. maintenance

New cards
50

how many lines can be written in an if statement without brackets?

one line

New cards
51

what is the difference between parsing and casting?

parsing is converting from string (you don’t risk losing any information), and casting is the narrowing or widening of primitive data types in which you risk losing information if you do a narrowing conversion

New cards
52

what is commenting used for?

used to explain your logic and make the program easier to follow/understand

New cards
53

what is a class?

a class is a generic template for a set of objects with similar features

New cards

Explore top notes

note Note
studied byStudied by 18 people
... ago
4.0(1)
note Note
studied byStudied by 12 people
... ago
5.0(1)
note Note
studied byStudied by 34 people
... ago
5.0(1)
note Note
studied byStudied by 13 people
... ago
5.0(2)
note Note
studied byStudied by 1 person
... ago
5.0(1)
note Note
studied byStudied by 57 people
... ago
5.0(1)
note Note
studied byStudied by 22 people
... ago
5.0(1)
note Note
studied byStudied by 1975 people
... ago
4.7(11)

Explore top flashcards

flashcards Flashcard (93)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (115)
studied byStudied by 13 people
... ago
5.0(2)
flashcards Flashcard (22)
studied byStudied by 17 people
... ago
5.0(3)
flashcards Flashcard (75)
studied byStudied by 2 people
... ago
5.0(1)
flashcards Flashcard (29)
studied byStudied by 27 people
... ago
5.0(2)
flashcards Flashcard (40)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (20)
studied byStudied by 1 person
... ago
5.0(1)
flashcards Flashcard (134)
studied byStudied by 2615 people
... ago
4.0(26)
robot