Data types in java script

Data types in java script

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

Escape Sequences: \'

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (60)

Section 1

(50 cards)

Escape Sequences: \'

Front

outputs: '

Back

Escape Sequences: \"

Front

outputs: "

Back

Escape Sequences: \b

Front

deletes previous character (backspace)

Back

Math return methods:

Front

floor(x) rounds x down ceil(x) rounds x up pow(x,y) returns x to the power of y abs(x) returns the absolute value of x sqrt(x) returns the square root of x round(x) rounds x to the nearest whole number min(x,y) returns smallest of x and y max(x,y) returns biggest of x and y random() returns a double >=0.0 and < 1.0 (random will give you a number from 0.0 to 0.99, not 1.0) (everything needs to start with Math.)

Back

Boolean conditions used:

Front

== equal != not equal <= less than or equal to >= greater than or equal to || or && and (if you are comparing strings use .equals)

Back

How do you write a If Else statement?

Front

if( boolean condition placed here ) { do something 1; } else { do something 2; }

Back

Formatting Output out.printf( " %9.2f " , 8.25612 );

Front

out.printf( " %9.2f " , 8.25612 ); 9 = column size .2 = # of decimals f = data type output == 8.26

Back

Constructors/Zero arg constructor

Front

Constructors set the properties of an object to an initial state. (often have parameters) public Triangle() { sideA=0; sideB=0; sideC=0; }

Back

what will this command do?: abdi++;

Front

it will increase abdi's value by one.

Back

More String methods

Front

indexOf( str ) returns the loc of String str in the string, searching from spot 0 to spot length-1 indexOf( ch ) returns the loc of char ch in the string, searching from spot 0 to spot length-1 lastIndexOf( str ) returns the loc of String str in the string, searching from spot length-1 to spot 0 lastIndexOf( ch ) returns the loc of char ch in the string, searching from spot length-1 to spot 0

Back

How do you compare two strings?

Front

you would use .equals() EX: String stringOne = "big"; if( stringOne.equals("it") ) { System.out.println("== it"); } if( stringOne.equals("big") ) { System.out.println("== big"); }

Back

length()

Front

returns the # of chars

Back

Given the following statement, var must be defined as which of the following types? var=keyboard.nextInt();

Front

int (Also, in the code "nextInt", "Int" has to be capitalized.

Back

long

Front

64 bits, big to big

Back

What is the output by the code below? String s = "Hello"; System.out.println("\String s");

Front

There is no output due to a syntax error. ( can't have those backslashes in the middle of code)

Back

substring(x,y)

Front

returns a section of the string from x to y not including y

Back

Given the following statement, var must be defined as which of the following types? var = keyboard.nextLine();

Front

String (for both nextLine & next you get a string)

Back

What is casting and what is an example of casting?

Front

Casting is often used to create compatibility among data types. EX: int one =0; double = 7.756; one=(int)dec;

Back

char

Front

16 bits, 0 - 65535

Back

Byte

Front

8 bits, -128 to 127

Back

logical operators: !x

Front

True if x is false

Back

How would you create a FOR LOOP?

Front

for(init value; boolean condition; increment) { doSomething(); } -the (init value) would be the starting number of times it will run -(boolean condition) decides when the loop stops running. the (increment) is the amount a value increases to end make the boolean condition true.

Back

substring(x)

Front

returns a section of the string from x to length-1

Back

Short

Front

16 bits, -327 to 327

Back

Int

Front

32 bits, -2 billion to 2 billion

Back

How many methods does class CS contain? public class CS { public void one() { System.out.print("one"); } }

Front

1

Back

what are instantiation?

Front

When you create a way to reference a method and/or code. EX: AplusBug dude = new AplusBug();

Back

How do you assign a variable without using a data type?

Front

abdi = 19;

Back

charAt(x)

Front

returns the char at spot x

Back

What of the following is not a legal reserved word for a java data type?

Front

integer (cause it it's "int" not integer)

Back

What is output by the following code given the input 11 15 25 30 Scanner kb = new Scanner( System.in ); kb.nextInt(); System.out.println( kb.nextInt() );

Front

15 (cause another command is inside the System.out.println, duuuuuhhh)

Back

Which of the following lines correctly defines an integer variable?

Front

int abdi = 16;

Back

Which of the following lines correctly defines a String variable?

Front

String s = "aplus";

Back

Operators used in math and examples:

Front

+ addition - subtraction * multiplication / division % modulus num = 45; out.println(num%10); 5 out.println(num/10); 4

Back

reference

Front

32 bitsl N/A

Back

In Java, every program statement ends with a what ?

Front

;

Back

What is encapsulation?

Front

All data members should have private access. A set of public methods should be provided to manipulate the private data.

Back

Methods frequently used for strings:

Front

equals(s) checks if this string has same chars as s compareTo(s) compares this string and s for >,<, and == trim() removes leading and trailing whitespace replaceAll(x,y) returns a new String with all x changed to y toUpperCase() returns a new String with uppercase chars toLowerCase() returns a new String with lowercase chars

Back

double

Front

64 bits, big to big

Back

Escape Sequences: \r

Front

moves in front of current line

Back

logical operators: x&&y

Front

both x and y must be true

Back

Example of lowercase method:

Front

char c = 'e'; out.println(c); c = Character.toUpperCase(c); Output: e

Back

Arrays in Strings

Front

A string is a group of characters. The first character in the group is at spot 0 and the last character is -1.

Back

How do you create a IF switch statement? and how does it work?

Front

int num = 30; switch(num) { case 11: System.out.println("num == 11"); break; case 30: System.out.println("num == 30"); break; } (This switch statement will check if num is equal to 11 and 30(case 11 & 30) if it is, it will print out the corresponding text, AND if it does not have a break; all conditons after the true statement will be executed untill the end or break; )

Back

float

Front

32 bits, big to big

Back

Escape Sequences: \\

Front

outputs: \

Back

Does PEMDAS affect the math equations?

Front

Yes, you need to follow the rules of PEMDAS

Back

String instantiation

Front

String s = "apluscompsci"; or String champ = new String("aplus"); s or champ is the reference variable. EX: String s = "apluscs"; int len = s.length(); System.out.println( len );

Back

Which of the following is the newline character?

Front


(remember, it is a backslash)

Back

logical operators: x||y

Front

either x or y must be true

Back

Section 2

(10 cards)

what are some ways to create a increment variable?

Front

score++; or score = score + 1;

Back

What will this command do? String s = "one two four five"; String[] words = s.split(" ");

Front

It will separate String s at all of the spaces and create it as a Array String named "words"

Back

How do i create a array variable?

Front

int[] abdi = {0,1,2,3,4,5}; (datatype)[] (name) = {(values)};

Back

how would you create a while loop?

Front

while(boolean condition placed here) { do somethingOne(); } a while loop will continue to run intil the condition becomes false.

Back

How would you make a Do while loop?

Front

do{ dosomethingOne(); } while(boolean condition placed here); the difference here is that a DO WHILE loop does the things first before checking the condition, It will continue to loop until

Back

what will this command do?: abdi--;

Front

it will decrease abdi's value by one.

Back

what does this command do?: aplus[0]= 9;

Front

It sets spot 0 to the value of 9.

Back

what will this command do?: String[] words = new String[10];

Front

I will create a String Array named "words" and make it have 11 indexes (because 0 counts)

Back

How would you import all plugins?

Front

import java.util.*;

Back

what would this command do?: intnums[] = {45,78,90,66,11}; Arrays.sort(nums);

Front

It will sort number and chars and strings

Back