Software Engineering Quiz 1

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

1/7

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.

8 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