Software Engineering Quiz 2

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

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.

15 Terms

1
New cards

Signiture of methods

public static void main(String[] args)

2
New cards

Printing in Java

System.out.println

println gives \n

3
New cards
System.out.println("Answer = " + 3 + 5);

Answer = 35 since 3 will be treated as a string

4
New cards

Ways to define a string (2)

String str1 = new String("Java");
String str2 = "Java"

Pointer:

  • Pointer to memory for the class

  • No need to delete since Java has garbage collector

Shortcut:

  • Special shortcut for strings

  • Adds Java to string pool

5
New cards
int x = 3;
int y = 3;
if (x == y) {
	System.out.println("x and y are equal!");
}

Prints fine since comparing values

6
New cards
if (str1 == str2) {
	System.out.println("Equal")
}

if (str1.equals(str2)) {
	System.out.println("Equal")
}

First one won’t print since str1 and str2 initialized differently

Second one is intended method

7
New cards

str1 and str2 both initialized by shortcut method (String str = “Java”)

if (str1 == str2) {
	System.out.println("Equal")
}

Prints fine since both are memory addresses pointing to the same string pool

8
New cards
str3.replace("+", "-")

What does this do?

Nothing! Since strings are immutable, replace returns pointer to newly created string in string pool

9
New cards

Java returns a __ to the _ of the array

pointer, first element

10
New cards

Code to create an array of 10 unknown doubles

double[] data = new double(10);

11
New cards

Code to create an array of ints containing 1,2,3

int[] nums = {1,2,3};

12
New cards

how to call length of an array called nums

nums.length

13
New cards

Contants use the __ keyword

final

14
New cards

Meaning of static keyword

Thing belongs to class itself, not an instance

15
New cards

Thing about accessing null in Java

Can print null, but can’t access null using . notation