{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

Learning Unit 3 Programming Theory Flashcards

(37 cards)

1
Q

\n (new line)

A

Forces a new line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

\t (tab space)

A
  • Indicates tab space
  • Cannot be used with showMessageDialog method
  • Work with standard text output system.out.println()
  • Leaves 8 spaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Not a

A

Primitive data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Strings are fundamental to Java

A

Has a number of features that we don’t find in other classes.
- The way a string object may be initialized.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Initializing a string involves using

A

A resolved word new.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

You can use char.At(_) method with

A

Objects of String class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Positions for string start at

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Has no parameters

A

In brackets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Java requires that any method name must be followed by an

A

Opening and closing bracket

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Can only be used with

A

String types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Methods of Math class are used for some

A

Are used for some mathematical operations which do not have operators in Java.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Important skill in programming

A

Find and use methods that have already been written to achieve your goal before your try to code your own solutions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Method is static

A

Called using class name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

No object needs

A

To be instantiated to call methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

NaN (Not a Number)

A

Is a run time error.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Math.pow();

A
  • Requires 2 parameters
  • Data type type of parameters: int/double
  • Function: returns the first value raised to the power of the second value.
  • Data type of return: double
17
Q

Math.round();

A
  • Requires: parameter
  • Data type of parameter: double
  • Function: returns round off value.
  • Data type of return: double
18
Q

Character values are written

A

Between single quotation marks.

19
Q

Characters are represented in Java

A

By Unicode character set.

20
Q

Unicode set:

A

A big table of all the characters on the keyboard as well as many more characters from different languages, Braille patterns and all sorts of symbols.

21
Q

Each character has a unique number

A

So that the computer can identify one from another.

22
Q

There are some special characters which we use quite often but do not have a single character symbol on the keyboard

A

(new line character/ return/enter and tab character)

23
Q

Escape sequences have unique Unicode values but

A

It is more convenient and understandable to express them using escape sequences.

24
Q

Instead of system.out.println() to display text on output screen, you can use

A

showMessageDialog() method of JOptionPane class to display in GUI

25
To gain access to showMessgaeDIalog method:
Import javax.swing.* package
26
Parameter null
Refers to GUI component the message is displayed in (frame). Since we don't have any GUI components, we use null for the first parameter (means 'nothin').
27
Two data type conversions
- Widening conversion - Narrowing conversion
28
Java performs widening conversions
Automatically
29
Narrowing conversions are not always safe
Data can be lost if value is outside possible range of values in new data type.
30
Java can be forced to perform a narrowing conversion using construct known as typecast/cast
Placing name of the desired data type in round brackets before value can be converted.
31
Narrowing conversion
Truncates (chops off) decimals of a real number when converting to integer.
32
Conversions should be avoided
If accuracy is to be preserved.
33
Cast operators are available
For several data types.
34
Formed by placing parenthesis
Around data type name immediately in front of the value to be converted.
35
No casting to convert from
String to int/double
36
println method converts all types to
String before displaying them.
37
Conversion could also be done by
Joining number to empty double quotes.