AP Computer Science A: Unit 2 Exam Questions & Answers/
AP Computer Science A: Unit 2 Exam Questions & Answers/ Consider the following variable declarations. int a = 5; int b = 4; double x = 5; double y = 4; Which of the following expressions would evaluate to the number, 1? 1. (int) x / y 2. a / b 3. a % b - -All of them. (1 , 2, and 3) Consider the following variable declarations. 1. double x = (int) 3.4 2. int y = (int) 5 / 2 , 5 3. String z = new String(" ") - -1 and 3 Consider String a below. Which of the following would create a new String with the value, "ram"? String a = new String ("Java Program"); - -String b = ring(9); Better code will NOT type in a static number to produce words near the end of the String and instead, uses length. Which of the following will result in "ram" in a better way than #2 did? - -String b = ring(h()-3); What special type of data is identified it has methods , unlike primitive data? Another giveaway that this is not primitive data is that variables of this type begin with a capital letter. - -Objects Consider the code segment below. What is the result that is printed on the screen? String six = new String ("Question 6"); int find = Of("q"); find = find + 2; Sln(find + Of("t"); -
Written for
- Institution
- AP Computer Science A
- Course
- AP Computer Science A
Document information
- Uploaded on
- January 25, 2024
- Number of pages
- 5
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
ap computer science a unit 2 exam questions ans