1.03k likes | 1.39k Views
Exam 1 Review. Exam 1. A lot of you found the exam to be very difficult as evidenced by some low scores. If you did not do well on the exam, please don’t panic. You will have the chance to make it up. How? We’ll get back to you on that. We are figuring out the details.
E N D
Exam 1 • A lot of you found the exam to be very difficult as evidenced by some low scores. • If you did not do well on the exam, please don’t panic. You will have the chance to make it up. • How? We’ll get back to you on that. We are figuring out the details. • In the meantime, learn from your mistakes! Take notes and ask questions as we review the exam. • Writing code outside of Eclipse is hard! We will work to ensure you get more practice. • Why is it important to be able to code without an IDE? • Demonstrates that you’ve grasped the concepts and don’t need a crutch to produce good code. • Coding interviews often take place on whiteboards. This is a good skill to develop early on. • I code on paper and whiteboards constantly. It’s often easier when sharing ideas with other developers. • AP exam • In-class exams
Section A: Question 1 All the following are primitive data types: int, char, double, boolean, String a) TRUE b) FALSE
Section A: Question 1 All the following are primitive data types: int, char, double, boolean, String a) TRUE b) FALSE
Section A: Question 2 The following is an example of an implicit cast: inta = (int) (5.0 / 9.0); a) TRUE b) FALSE
Section A: Question 2 The following is an example of an implicit cast: inta = (int) (5.0 / 9.0); a) TRUE b) FALSE
Explicit cast vs. implicit cast An implicit cast occurs when the cast is automatically done by the compiler and no code is required. inti = 3; double d = 3; public static compute(double d) {…} compute(42); An explicit cast requires code from the programmer to inform the compiler of the cast. inti = (int)(Math.sqrt(2));
Section A: Question 3 The concatenation operator is the plus sign. a) TRUE b) FALSE
Section A: Question 3 The concatenation operator is the plus sign. a) TRUE b) FALSE
Section A: Question 4 Adding a double and an int implicitly converts the int variable to a double and the sum is a double. a) TRUE b) FALSE
Section A: Question 4 Adding a double and an int implicitly converts the int variable to a double and the sum is a double. a) TRUE b) FALSE
Section A: Question 5 inta = 9; int b = 5; for (inti = 0; i <= a; i++){ b = b + i; a = a - i; } a) a = -36, b = 9 b) a = -36, b = 50 c) a = 3, b = 11 d) a = 9, b = 50 e) a = 9, b = 11
Section A: Question 5 inta = 9; int b = 5; for (inti = 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 5 i = 0
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a= 9 b= 5 i= 0
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 5 i = 0
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 5 i = 0
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 5 i = 1
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 5 i = 1
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 9 b = 6 i = 1
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 8 b = 6 i = 1
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 8 b = 6 i = 2
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 8 b = 6 i = 2
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 8 b = 8 i = 2
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 6 b = 8 i = 2
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 6 b = 8 i = 3
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 6 b = 8 i = 3
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 6 b = 11 i = 3
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 3 b = 11 i = 3
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 3 b = 11 i = 4
Section A: Question 5 inta = 9; int b = 5; for (inti= 0; i <= a; i++){ b = b + i; a = a - i; } a = 3 b = 11 i = 4
Section A: Question 5 inta = 9; int b = 5; for (inti = 0; i <= a; i++){ b = b + i; a = a - i; } a) a = -36, b = 9 b) a = -36, b = 50 c) a = 3, b = 11 d) a = 9, b = 50 e) a = 9, b = 11
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } a) 4 3 5 b) 4 3 5 4 c) 4 3 2 5 4 3 d) 1 3 1 2 2 3 e) 1 3 1 2 2 3 2 2
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = output:
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = output:
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 3 output:
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 3 output:
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i= 1 j= 3 output: 4
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i= 1 j= 2 output: 4
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 2 output: 4
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 2 output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 1 output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 1 j = 1 output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j = output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i= 2 j = output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j = 3 output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j = 3 output: 4 3
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j = 3 output: 4 3 5
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j= 2 output: 4 3 5
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 2 j = 2 output: 4 3 5
Section A: Question 6 for (inti = 1; i < 3; i++){ for (int j = 3; j > i; j--){ System.out.print(i+j + " "); } } i = 3 j = output: 4 3 5