Unit 2 Lesson 1-4 notes

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What will be printed by the following code? System.out.print("All\nright\tnow");

All right now

______ data types can hold several pieces of data and have methods to work on that data.

Class

______ data types hold the memory address of where the data is stored.

Class

What is stored in w1 by the following? (with the word banana) w1 = w3.substring(2);

nana

A special value that can be assigned to an object that has no value:

null

What is the output? (with the word banana) System.out.println(w3.compareTo("fruit"));

-4

To output: Nums: 12 13 14 15 You would need to use what escape sequence in the blank: System.out.print("Nums: 12 13 14______15");

/t

Which of the following code segments correctly declare a String s and gives it a value of "fortran"?

1. String s; s = "fortran"; 2. String s = "fortran"; 3. String s = ("fortran");

Which of the following are true about class data types?

1. a programmer can them 2. holds more than one piece of data at a time 3. has built in methods (tools)

Consider the following code: int x = 9; int y = 8; System.out.println(x + y); What is output?

17

Which one of the following sentences is true?

A String is a class data type so a String variable holds a reference to a location in memory

Which of the following best describes the relationship between a class and an object?

A class is a template or blueprint from which an object can be created.

Consider the following code: String a = "CSA"; String b = a;a = "AP"; System.out.println(a + " " + b); What is printed when the code is run? Hint: Remember Strings are immutable.

AP CSA

Consider the following code: int x = 56; int y = 30; System.out.print("Answer: " + x + y); This code outputs: Answer: 86 True or false?

False

______ data types hold only one piece of information at a time.

Primitive

Which code shows us creating an object of data type Scanner class and storing it with a variable named X ?

Scanner X = new Scanner(System.in);

Examples of classes

String and Scanner

Which of the following would set the String variable firstName to be completely empty (i.e. not even storing a memory address)?

String firstName = null;

Which of the following correctly declares a new variable which can be used to point to an object of the String class type?

String str;

Which of the following commands will print the output below? \/ ''

System.out.print("\\/\n\'\'")

Consider the following code: System.out.println("Answer: " + (2 + 5)); This code outputs: Answer: 7 True or false?

True

Which of the following symbols need an escape character to be output in a System.out.print statement?

\

What is stored in w1 by the following? (with the word banana) w1 = w3.substring(1,3);

an


Set pelajaran terkait

IT195 Customer Service Skills for the Service Desk Professional - Chapter 3 - NO TRUE/FALSE

View Set

What Was the Wild West questions

View Set

1610 - Jamestown: John Rolfe (Pocahontas & John Smith)

View Set

NCLEX Musculoskeletal & Neurological disorders

View Set

MedSurg II - Exam 3 - Ch. 57 Burns, Ch. 28, 29, 30

View Set

1. Inductive 2. Deductive 3. Reasoning 4. Logic 5. Appeal 6. Evidence 7. Facts 8. Argument 9. Persuasion 10. Thesis 11. Generalization 12. Conclusion 13. Claim 14. Hypothesis 15. Ethos 16. Rebuttal 17. Essay

View Set

Quiz 4 Oxygen Therapy and Respiratory Care Chapter 87

View Set

Making Electric Current with Magnets

View Set

Exam #2 (CH 41 Musculoskeletal Care)

View Set

Ch. 67: Management of Patients with Cerebrovascular Disorders

View Set