6) Is the following loop correct?for (; ; ); 6)

Size: px
Start display at page:

Download "6) Is the following loop correct?for (; ; ); 6)"

Transcription

1 Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) You can always convert a while loop to a for loop. 1) 2) Will the following program terminate?int balance = 10;while (true) { if (balance < 9) break; balance = balance - 9;} 2) A) Yes B) No 3) You can always write a program without using break or continue in a loop. 4) What is sum after the following loop terminates?int sum = 0;int item = 0;do { item++; sum += item; if (sum >= 4) continue;}while (item < 5); 3) 4) A) 18 B) 16 C) 15 D) 17 5) Analyze the following code.int count = 0;while (count < 100) { // Point A System.out.println("Welcome to Java!"); count++; // Point B} // Point C 5) (choose all that apply) A) count < 100 is always false at Point C B) count < 100 is always false at Point B C) count < 100 is always true at Point C D) count < 100 is always true at Point A E) count < 100 is always true at Point B 6) Is the following loop correct?for (; ; ); 6) A) Yes B) No 7) What is sum after the following loop terminates?int sum = 0;int item = 0;do { item++; sum += item; if (sum > 4) break;}while (item < 5); 7) A) 7 B) 8 C) 6 D) 5 8) How many times will the following code print "Welcome to Java"?int count = 0;do { System.out.println("Welcome to Java");} while (count++ < 10); 8) A) 11 B) 9 C) 0 D) 10 E) 8 9) To add , what order should you use to add the numbers to get better accuracy? A) add 1.00, 0.99, 0.98,..., 0.02, 0.01 in this order to a sum variable whose initial value is 0. B) add 0.01, 0.02,..., 1.00 in this order to a sum variable whose initial 9)

2 value is 0. 10) What is the number of iterations in the following loop: for (int i = 1; i <= n; i++) { // iteration } 10) A) n + 1 B) n - 1 C) 2*n D) n 11) Analyze the following statement:double sum = 0;for (double d = 0; d<10;) { d += 0.1; sum += sum + d;} 11) A) The program has a syntax error because the adjustment is missing in the for loop. B) The program runs in an infinite loop because d<10 would always be true. C) The program has a syntax error because the control variable in the for loop cannot be of the double type. D) The program compiles and runs fine. 12) Analyze the following fragment:double sum = 0;double d = 0;while (d!= 10.0) { d += 0.1; sum += sum + d;} 12) A) After the loop, sum is B) The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers. C) The program does not compile because sum and d are declared double, but assigned with integer value 0. D) The program never stops because d is always 0.1 inside the loop. 13) What is == 3.0? 13) A) true B) false C) There is no guarantee that == 3.0 is true. 14) What is the output of the following fragment? for (int i = 0; i < 15; i++) { if (i % 4 == 1) System.out.print(i + " "); } 14) A) B) C) D) E) ) What is y after the following for loop statement is executed?int y = 0;for (int i = 0; i < 10; ++i) { y += 1; } 15) A) 10 B) 9 C) 11 D) 12 16) What the output of the following code:for ( ; false ; ) System.out.println("Welcome to Java"); 16) A) prints out Welcome to Java one time. B) prints out Welcome to Java two times.

3 C) does not print anything. D) prints out Welcome to Java forever. 17) After the continue outer statement is executed in the following loop, which statement is executed? outer: for (int i = 1; i < 10; i++) { inner: for (int j = 1; j < 10; j++) { if (i * j > 50) continue outer; System.out.println(i * j); } } next: A) The program terminates. B) The control is in the inner loop, and the next iteration of the inner loop is executed. C) The control is in the outer loop, and the next iteration of the outer loop is executed. D) The statement labeled next. 18) Will the following program terminate?int balance = 10;while (true) { if (balance < 9) continue; balance = balance - 9;} 17) 18) A) Yes B) No 19) What is the output for y?int y = 0;for (int i = 0; i<10; ++i) { y += i; }System.out.println(y); A) 13 B) 45 C) 11 D) 10 E) 12 20) What is the output of the following fragment?int i = 1;int j = 1;while (i < 5) { i++; j = j * 2;}System.out.println(j); 19) 20) A) 16 B) 8 C) 4 D) 32 E) 64 21) What is the value in count after the following loop is executed?int count = 0;do { System.out.println("Welcome to Java");} while (count++ < 9);System.out.println(count); 21) A) 8 B) 9 C) 11 D) 0 E) 10 22) How many times will the following code print "Welcome to Java"?int count = 0;while (count < 10) { System.out.println("Welcome to Java"); count++;} 22) A) 11 B) 0 C) 8 D) 9 E) 10 23) After the break outer statement is executed in the following loop, which statement is executed? outer: for (int i = 1; i < 10; i++) { inner: for (int j = 1; j < 10; j++) { if (i * j > 50) break outer; System.out.println(i * j); } } next: A) The program terminates. B) The statement labeled inner. C) The statement labeled outer. D) The statement labeled next. 24) Assume x is 0. What is the output of the following statement?if (x > 0) printf("x is greater than 0");else if (x < 0) printf("x is less than 0");else printf("x equals 0"); 23) 24)

4 A) x equals 0 B) x is greater than 0 C) x is less than 0 D) None 25) What balance after the following code is executed?int balance = 10;while (balance >= 1) { if (balance < 9) continue; balance = balance - 9;} 25) A) 1 B) The loop does not end C) 2 D) -1 E) 0 26) What is Math.round(3.6)? 26) A) 3.0 B) 4.0 C) 4 D) 3 27) is a simple but incomplete version of a method. 27) A) A main method B) A stub C) A method developed using top-down approach D) A non-main method 28) Which of the following is a possible output for (int)(51* Math.random())? (choose all that apply) A) 0 B) 50 C) 500 D) ) Analyze the following code.public class Test { public static void main(string[] args) { System.out.println(m(2)); } public static int m(int num) { return num; } public static void m(int num) { System.out.println(num); }} 28) 29) A) The program runs and prints 2 once. B) The program has a syntax error because the second m method is defined, but not invoked in the main method. C) The program runs and prints 2 twice. D) The program has a syntax error because the two methods m have the same signature. 30) What is Math.floor(3.6)? 30) A) 5.0 B) 4 C) 3.0 D) 3 31) Does the method call in the following method cause syntax errors?public static void main(string[] args) { Math.pow(2, 4);} 31) A) Yes B) No 32) Suppose static void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; }}What is the printout of the call nprint('a', 4)? 32) A) aaa B) aaaa C) aaaaa D) invalid call

5 33) Which of the following method results in 8.0? (choose all that apply) 33) A) Math.rint(8.5) B) Math.ceil(8.5) C) Math.round(8.5) D) Math.floor(8.5) 34) A method can be defined inside a method in Java. 34) 35) Math.floor(5.5) evaluates to. 35) A) 5 B) 6 C) 5.0 D) ) Math.ceil(5.5) evaluates to. 36) A) 6 B) 6.0 C) 5.0 D) 5 37) Suppose static void nprint(string message, int n) { while (n > 0) { System.out.print(message); n--; }}What is k after invoking nprint("a message", k)?int k = 2;nPrint("A message", k); 37) A) 0 B) 2 C) 3 D) 1 38) Analyze the following code:class Test { public static void main(string[] args) { System.out.println(xMethod((double)5)); } public static int xmethod(int n) { System.out.println("int"); return n; } public static long xmethod(long n) { System.out.println("long"); return n; }} A) The program displays long followed by 5. B) The program displays int followed by 5. C) The program runs fine but displays things other than given in A and B. D) The program does not compile. 39) You can define two methods in the same class with the same name and parameter list. 38) 39) 40) Which of the following should be declared as a void method? 40) A) Write a method that checks whether current second is today is integers from 1 to 100. B) Write a method that returns a random integer from 1 to 100. C) Write a method that converts an uppercase letter to lowercase. D) Write a method that prints integers from 1 to ) A variable defined inside a method is referred to as. 41) A) a local variable B) a block variable C) a global variable D) a method variable 42) Each time a method is invoked, the system stores parameters and local variables in an area of memory, known as, which stores elements in last-in first-out fashion. A) a stack B) storage area C) a heap D) an array 42) 43) is to implement one method in the structure chart at a time fro m the

6 top to the bottom. 43) A) Bottom-up and top-down approach B) Bottom-up approach C) Top-down approach D) Stepwise refinement 44) Analyze the following code:public class Test { public static void main(string[] args) { int[] oldlist = {1, 2, 3, 4, 5}; reverse(oldlist); for (int i = 0; i < oldlist.length; i++) System.out.print(oldList[i] + ""); } public static void reverse(int[] list) { int[] newlist = new int[list.length]; for (int i = 0; i < list.length; i++) newlist[i] = list[list.length i]; list = newlist; }} 44) A) The program displays and then raises an ArrayIndexOutOfBoundsException. B) The program displays and then raises an ArrayIndexOutOfBoundsException. C) The program displays D) The program displays ) The array size is specified when the array is declared. 45) 46) Analyze the following code.public class Test { public static void main(string[] args) { int[] x = new int[3]; System.out.println("x[0] is " + x[0]); }} 46) A) The program has a runtime error because the array element x[0] is not defined. B) The program has a runtime error because the array elements are not initialized. C) The program has a syntax error because the size of the array wasn't specified when declaring the array. D) The program runs fine and displays x[0] is 0. 47) Consider the following statements:int[] numbers = new int[10];int[] numbers = new int[5];what is numbers.length? A) 10. B) 5 C) undefined. D) The above statements are illegal. 48) Show the output of the following code:public class Test { public static void main(string[] args) { int[] x = {1, 2, 3, 4, 5}; increase(x); int[] y = {1, 2, 3, 4, 5}; increase(y[0]); System.out.println(x[0] + "" + y[0]); } public static void increase(int[] x) { for (int i = 0; i < x.length; i++) x[i]++; } public static void increase(int y) { y++; }} 47) 48)

7 A) 2 2 B) 0 0 C) 1 1 D) 2 1 E) ) Given the following statement int[ ] list = new int[10]; list.length has the value A) 9 B) 11 C) 10 D) The value depends on how many integers are stored in list. 50) Given the following declaration: int[ ][] m = new int[5][6]; Which of the following statements is true? A) The name m represents a two-dimensional array of 30 int values. B) m[2][4] represents the element stored in the 2nd row and the 4th column of m. C) m[0].length has the value 5. D) m.length has the value 6. 51) Analyze the following code:public class Test { public static void main(string[] args) { final int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for (int i = 0; i < y.length; i++) System.out.print(y[i] + " "); }} 49) 50) 51) A) The program displays 0 0 B) The program has a syntax error on the statement x = new int[2], because x is final and cannot be changed. C) The program displays D) The elements in the array x cannot be changed, because x is final. 52) Analyze the following code:public class Test1 { public static void main(string[] args) { xmethod(new double[]{3, 3}); xmethod(new double[5]); xmethod(new double[3]{1, 2, 3}); } public static void xmethod(double[] a) { System.out.println(a.length); }} 52) A) The program has a syntax error because xmethod(new double[3]{1, 2, 3}) is incorrect. B) The program has a runtime error because a is null. C) The program has a syntax error because xmethod(new double[5]) is incorrect. D) The program has a syntax error because xmethod(new double[]{3, 3}) is incorrect. 53) In the following code, what is the printout for list1?class Test { public static void main(string[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list1.length; i++) System.out.print(list1[i] + ""); }} 53) A) B) C) D) ) The array index is not limited to int type. 54)

8 55) What would be the result of attempting to compile and run the following code? public class Test { public static void main(string[] args) { double[] x = new double[]{1, 2, 3}; System.out.println("Value is " + x[1]); }} 55) A) The program has a syntax error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[3]{1, 2, 3}; B) The program has a syntax error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by new double[]{1.0, 2.0, 3.0}; C) The program compiles and runs fine and the output "Value is 2.0" is printed. D) The program has a syntax error because the syntax new double[]{1, 2, 3} is wrong and it should be replaced by {1, 2, 3}. E) The program compiles and runs fine and the output "Value is 1.0" is printed. 56) Which of the following declarations are correct? (choose all that apply) 56) A) public static void print(double... numbers) B) public static double... print(double d1, double d2) C) public static void print(string... strings, double... numbers) D) public static void print(int n, double... numbers) E) public static void print(double... numbers, String name) 57) When you return an array from a method, the method returns. 57) A) the reference of the array B) a copy of the first element C) the length of the array D) a copy of the array 58) The size of can grow and shrink at runtime. 58) A) an ArrayList B) an array 59) Normally you depend on the JVM to perform garbage collection automatically. However, you can explicitly use to request garbage collection. A) System.gc(0) B) System.gc() C) System.exit() D) System.exit(0) 60) Analyze the following code.// Program 1:public class Test { public static void main(string[] args) { Object a1 = new A(); Object a2 = new A(); System.out.println(a1.equals(a2)); }}class A { int x; public boolean equals(a a) { return this.x == a.x; }}// Program 2:public class Test { public static void main(string[] args) { A a1 = new A(); A a2 = new A(); System.out.println(a1.equals(a2)); }}class A { int x; public boolean equals(a a) { return this.x == a.x; }} A) Program 1 displays false and Program 2 displays true B) Program 1 displays false and Program 2 displays false C) Program 1 displays true and Program 2 displays false D) Program 1 displays true and Program 2 displays true 59) 60)

9 61) Given the following code, find the syntax error?public class Test { public static void main(string[] args) { m(new GraduateStudent()); m(new Student()); m(new Person()); m(new Object()); } public static void m(student x) { System.out.println(x.toString()); }}class GraduateStudent extends Student {}class Student extends Person { public String tostring() { return "Student"; }}class Person extends Object { public String tostring() { return "Person"; }} 61) (choose all that apply) A) m(new Object()) causes an error B) m(new Student()) causes an error C) m(new GraduateStudent()) causes an error D) m(new Person()) causes an error 62) Analyze the following code:public class Test { public static void main(string[] args) { Object a1 = new A(); Object a2 = new Object(); System.out.println(a1); System.out.println(a2); }}class A { int x; public String tostring() { return "A's x is " + x; }} 62) (choose all that apply) A) When executing System.out.println(a2), the tostring() method in the Object class is invoked. B) The program cannot be compiled, because System.out.println(a1) is wrong and it should be replaced by System.out.println(a1.toString()); C) When executing System.out.println(a1), the tostring() method in the Object class is invoked. D) When executing System.out.println(a1), the tostring() method in the A class is invoked. 63) If a parameter is of the java.lang.object type, you can pass any object to it. This is known as generic programming. 63) 64) Which of the following statements are true? (choose all that apply) 64) A) It is a compilation error if two methods differ only in return type. B) A private method cannot be overridden. If a method defined in a subclass is private in its superclass, the two methods are completely unrelated. C) To override a method, the method must be defined in the subclass using the same signature and return type as in its superclass. D) Overloading a method is to provide more than one method with the same name but with different signatures to distinguish them. E) A static method cannot be overridden. If a static method defined in the superclass is redefined in a subclass, the method defined in the superclass is hidden. 65) The UML uses before a member name to indicate that the me mber is

10 private. 65) A) + B) - C) # D) None of the above. 66) The getvalue() method is overridden in two ways. Which one is correct?i:public class Test { public static void main(string[] args) { A a = new A(); System.out.println(a.getValue()); }}class B { public String getvalue() { return "Any object"; }}class A extends B { public Object getvalue() { return "A string"; }}II:public class Test { public static void main(string[] args) { A a = new A(); System.out.println(a.getValue()); }}class B { public Object getvalue() { return "Any object"; }}class A extends B { public String getvalue() { return "A string"; }} 66) A) I B) II C) Neither D) Both I and II 67) Which of the following statements are true? (choose all that apply) 67) A) A subclass is a subset of a superclass. B) "class A extends B" means B is a subclass of A. C) A subclass is usually extended to contain more functions and more detailed information than its superclass. D) "class A extends B" means A is a subclass of B. 68) Which of the following loops produces the following output? (choose all that apply) (I) for (int i = 5; i > 0; i--) { for (int j = 1; j < i; j++) System.out.print(j + ""); System.out.println(); }(II) for (int i = 1; i < 5; i++) { for (int j = 1; j < i; j++) System.out.print(j + ""); System.out.println(); } (III) int i = 0;while (i < 5) { for (int j = 1; j < i; j++) System.out.print(j + ""); System.out.println(); i++; }(IV) int i = 5;while (i > 0) { for (int j = 1; j < i; j++) System.out.print(j + " "); System.out.println(); i--; } 68) A) (I) B) (II) C) (IV) D) (III) 69) How many times will the following code print "Welcome to Java"?int count = 0;do { System.out.println("Welcome to Java");} while (++count < 10); 69) A) 0 B) 8 C) 9 D) 10 E) 11 70) You can always convert a for loop to a while loop. 70) 71) Analyze the following code. int x = 1; while (0 < x) && (x < 100) System.out.println(x++); 71) A) The code does not compile because (0 < x) && (x < 100) is not enclosed in a pair of parentheses.

11 B) The numbers 1 to 99 are displayed. C) The loop runs for ever. D) The numbers 2 to 100 are displayed. E) The code does not compile because the loop body is not in the braces. 72) In a for statement, if the continuation condition is blank, the condition is assumed to be. 73) The while loop and the do loop are equivalent in their expressive power; in other words, you can rewrite a while loop using a do loop, and vice versa. 74) Suppose cond1 is a Boolean expression. When will this while condition be true?while (cond1)... 72) 73) 74) A) always false B) in case cond1 is false C) in case cond1 is true D) always true 75) A break statement can be used only in a loop. 75) 76) The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as.(choose all that apply) A) method hiding B) encapsulation C) simplifying method D) information hiding 76) 77) Which of the following is not an advantage of using methods? 77) A) Using methods makes programs easier to read. B) Using methods makes reusing code easier. C) Using methods hides detailed implementation from the clients. D) Using methods makes programs run faster. 78) Variables defined in the method header are called. 78) A) parameters B) arguments C) local variables D) global variables 79) When you invoke a method with a parameter, the value of the argument is passed to the parameter. This is referred to as. A) method invocation B) pass by value C) pass by reference D) pass by name 79) 80) Math.sqrt(4) returns. 80) A) 1 B) 2 C) 1.0 D) ) Which of the following is a possible output from invoking Math.random()? (choose all that apply) A) 1.0 B) 3.43 C) 0.5 D) )

12 82) Analyze the following code.int[] list = new int[5];list = new int[6]; 82) A) The code has syntax errors because the variable list cannot be changed once it is assigned. B) The code can compile and run fine. The second line assigns a new array to list. C) The code has syntax errors because you cannot assign a different size array to list. D) The code has runtime errors because the variable list cannot be changed once it is assigned. 83) Suppose a method p has the following heading:public static int[][] p()what return statement may be used in p()? A) return new int[]{1, 2, 3}; B) return 1; C) return {1, 2, 3}; D) return new int[][]{{1, 2, 3}, {2, 4, 5}}; E) return int[]{1, 2, 3}; 84) Analyze the following code: int[][] matrix = new int[5][5]; for (int column = 0; column < matrix[4].length; column++) matrix[4][column] = 10; A) After the loop, the last row of matrix 10, 10, 10, 10, 10. B) After the loop, the last column of matrix 10, 10, 10, 10, 10. C) After the loop, the last row of matrix 0, 0, 0, 0, 10. D) After the loop, the last row of matrix 0, 0, 0, 0, 0. 85) In the following code, what is the printout for list2?class Test { public static void main(string[] args) { int[] list1 = {3, 2, 1}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = list2.length - 1; i >= 0; i--) System.out.print(list2[i] + ""); }} A) 013. B) 321 C) 123 D) 012 E) ) 84) 85) 86) Which of the statements regarding the super keyword is incorrect? 86) A) You cannot invoke a method in superclass's parent class. B) You can use super to invoke a super class method. C) You can use super.super.p to invoke a method in superclass's parent class. D) You can use super to invoke a super class constructor. 87) Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the following method will cause the list to become [Beijing, Chicago, Singapore]? A) x.add(2, "Chicago") B) x.add(0, "Chicago") C) x.add("chicago") D) x.add(1, "Chicago") 88) You can use the operator == to check whether two variables refer to the same object, and use the equals() method to check the equality of contents of the two objects. 87) 88)

13 89) What is the value of balance after the following code is executed?int balance = 10;while (balance >= 1) { if (balance < 9) break; balance = balance - 9;} 89) A) 1 B) -1 C) 0 D) 2 90) What is i after the following for loop?int y = 0;for (int i = 0; i<10; ++i) { y += i; } 90) A) 10 B) undefined C) 11 D) 9 91) Which of the following expression yields an integer between 0 and 100, inclusive? A) (int)(math.random() * 100) B) (int)(math.random() * ) C) (int)(math.random() * 101) D) (int)(math.random() * 100) ) The actual parameters of a method must match the formal parameters in type, order, and number. 93) The signature of a method consists of the method name, parameter list and return type 94) Suppose a method p has the following heading:public static int[] p()what return statement may be used in p()? A) return int[]{1, 2, 3}; B) return new int[]{1, 2, 3}; C) return 1; D) return {1, 2, 3}; 91) 92) 93) 94) 95) Which of the following are Java keywords? 95) A) instanceof B) casting C) cast D) instanceof 96) What is the number of iterations in the following loop: for (int i = 1; i < n; i++) { // iteration } A) 2*n B) n + 1 C) n D) n ) The modifiers and return value type do not contribute toward distinguishing one method from another, only the parameter list. 96) 97) 98) Suppose int[] numbers = new int[10], what is numbers[0]? 98) A) undefined B) 0 C) 10 D) null 99) can search in an unsorted list. 99) A) Binary search B) Linear search 100) What the output of the following code:for ( ; ; ) System.out.println("Welcome to Java"); 100)

14 A) prints out Welcome to Java two times. B) prints out Welcome to Java one time. C) prints out Welcome to Java forever. D) does not print anything.

15 1) A 2) A 3) A 4) C 5) A, D 6) A 7) C 8) A 9) B 10) D 11) D 12) B 13) C 14) E 15) A 16) C 17) C 18) B 19) B 20) A 21) E 22) E 23) D 24) A 25) B 26) C 27) B 28) A, B 29) D 30) C 31) B 32) D 33) A, D 34) B 35) C 36) B 37) B 38) D 39) B 40) D 41) A 42) A 43) C 44) C 45) B 46) D 47) A 48) D 49) C 50) A 51) B

16 52) A 53) A 54) B 55) C 56) A, D 57) A 58) A 59) B 60) A 61) A, D 62) A, D 63) A 64) A, B, C, D, E 65) B 66) B 67) C, D 68) A, C 69) D 70) A 71) A 72) A 73) A 74) B 75) B 76) B, D 77) D 78) A 79) B 80) D 81) C, D 82) B 83) D 84) A 85) E 86) C 87) D 88) A 89) A 90) B 91) C 92) A 93) B 94) B 95) D 96) D 97) A 98) B 99) B 100) C

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Iteration CHAPTER 6. Topic Summary

Iteration CHAPTER 6. Topic Summary CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many

More information

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19

COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005. Question Out of Mark A Total 16. B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 Term Test #2 COSC 1020 3.0 Introduction to Computer Science I Section A, Summer 2005 Family Name: Given Name(s): Student Number: Question Out of Mark A Total 16 B-1 7 B-2 4 B-3 4 B-4 4 B Total 19 C-1 4

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

Part I. Multiple Choice Questions (2 points each):

Part I. Multiple Choice Questions (2 points each): Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

Statements and Control Flow

Statements and Control Flow Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to

More information

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be:

You are to simulate the process by making a record of the balls chosen, in the sequence in which they are chosen. Typical output for a run would be: Lecture 7 Picking Balls From an Urn The problem: An urn has n (n = 10) balls numbered from 0 to 9 A ball is selected at random, its' is number noted, it is set aside, and another ball is selected from

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1. Software Organization View to this point: CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

More information

LOOPS CHAPTER CHAPTER GOALS

LOOPS CHAPTER CHAPTER GOALS jfe_ch04_7.fm Page 139 Friday, May 8, 2009 2:45 PM LOOPS CHAPTER 4 CHAPTER GOALS To learn about while, for, and do loops To become familiar with common loop algorithms To understand nested loops To implement

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

JAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below:

JAVA - METHODS. Method definition consists of a method header and a method body. The same is shown below: http://www.tutorialspoint.com/java/java_methods.htm JAVA - METHODS Copyright tutorialspoint.com A Java method is a collection of statements that are grouped together to perform an operation. When you call

More information

System.out.println("\nEnter Product Number 1-5 (0 to stop and view summary) :

System.out.println(\nEnter Product Number 1-5 (0 to stop and view summary) : Benjamin Michael Java Homework 3 10/31/2012 1) Sales.java Code // Sales.java // Program calculates sales, based on an input of product // number and quantity sold import java.util.scanner; public class

More information

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Example of a Java program

Example of a Java program Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

More information

CS170 Lab 11 Abstract Data Types & Objects

CS170 Lab 11 Abstract Data Types & Objects CS170 Lab 11 Abstract Data Types & Objects Introduction: Abstract Data Type (ADT) An abstract data type is commonly known as a class of objects An abstract data type in a program is used to represent (the

More information

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75

Preet raj Core Java and Databases CS4PR. Time Allotted: 3 Hours. Final Exam: Total Possible Points 75 Preet raj Core Java and Databases CS4PR Time Allotted: 3 Hours Final Exam: Total Possible Points 75 Q1. What is difference between overloading and overriding? 10 points a) In overloading, there is a relationship

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2015 The third

More information

Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

More information

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program Free Java textbook available online "Thinking in Java" by Bruce Eckel, 4th edition, 2006, ISBN 0131872486, Pearson Education Introduction to the Java programming language CS 4354 Summer II 2014 Jill Seaman

More information

Arrays in Java. Working with Arrays

Arrays in Java. Working with Arrays Arrays in Java So far we have talked about variables as a storage location for a single value of a particular data type. We can also define a variable in such a way that it can store multiple values. Such

More information

Chapter 13 - Inheritance

Chapter 13 - Inheritance Goals Chapter 13 - Inheritance To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package

More information

5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int.

5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int. Java How to Program, 5/e Test Item File 1 of 5 Chapter 5 Section 5.2 5.2 Q1 Counter-controlled repetition requires a.a control variable and initial value. b.a control variable increment (or decrement).

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

Java Programming Language

Java Programming Language Lecture 1 Part II Java Programming Language Additional Features and Constructs Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Subclasses and

More information

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Software Testing Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program. Testing can only reveal the presence of errors and not the

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

Section 6 Spring 2013

Section 6 Spring 2013 Print Your Name You may use one page of hand written notes (both sides) and a dictionary. No i-phones, calculators or any other type of non-organic computer. Do not take this exam if you are sick. Once

More information

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION

MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION MIDTERM 1 REVIEW WRITING CODE POSSIBLE SOLUTION 1. Write a loop that computes (No need to write a complete program) 100 1 99 2 98 3 97... 4 3 98 2 99 1 100 Note: this is not the only solution; double sum

More information

Arrays. Introduction. Chapter 7

Arrays. Introduction. Chapter 7 CH07 p375-436 1/30/07 1:02 PM Page 375 Chapter 7 Arrays Introduction The sequential nature of files severely limits the number of interesting things you can easily do with them.the algorithms we have examined

More information

CMSC 202H. ArrayList, Multidimensional Arrays

CMSC 202H. ArrayList, Multidimensional Arrays CMSC 202H ArrayList, Multidimensional Arrays What s an Array List ArrayList is a class in the standard Java libraries that can hold any type of object an object that can grow and shrink while your program

More information

Fundamentals of Java Programming

Fundamentals of Java Programming Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors

More information

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013 Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper

More information

Basic Programming and PC Skills: Basic Programming and PC Skills:

Basic Programming and PC Skills: Basic Programming and PC Skills: Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of

More information

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

More information

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

More information

C++FA 5.1 PRACTICE MID-TERM EXAM

C++FA 5.1 PRACTICE MID-TERM EXAM C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer

More information

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0 The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized

More information

Chapter 1 Java Program Design and Development

Chapter 1 Java Program Design and Development presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system. http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral

More information

Java Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types

Java Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types Interfaces & Java Types Lecture 10 CS211 Fall 2005 Java Interfaces So far, we have mostly talked about interfaces informally, in the English sense of the word An interface describes how a client interacts

More information

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius

1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius Programming Concepts Practice Test 1 1) Which of the following is a constant, according to Java naming conventions? a. PI b. Test c. x d. radius 2) Consider the following statement: System.out.println("1

More information

Part 3: GridWorld Classes and Interfaces

Part 3: GridWorld Classes and Interfaces GridWorld Case Study Part 3: GridWorld Classes and Interfaces In our example programs, a grid contains actors that are instances of classes that extend the Actor class. There are two classes that implement

More information

Sample CSE8A midterm Multiple Choice (circle one)

Sample CSE8A midterm Multiple Choice (circle one) Sample midterm Multiple Choice (circle one) (2 pts) Evaluate the following Boolean expressions and indicate whether short-circuiting happened during evaluation: Assume variables with the following names

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

Java Programming Fundamentals

Java Programming Fundamentals Lecture 1 Part I Java Programming Fundamentals Topics in Quantitative Finance: Numerical Solutions of Partial Differential Equations Instructor: Iraj Kani Introduction to Java We start by making a few

More information

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.

Arrays. Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays. Arrays Atul Prakash Readings: Chapter 10, Downey Sun s Java tutorial on Arrays: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html 1 Grid in Assignment 2 How do you represent the state

More information

Description of Class Mutation Mutation Operators for Java

Description of Class Mutation Mutation Operators for Java Description of Class Mutation Mutation Operators for Java Yu-Seung Ma Electronics and Telecommunications Research Institute, Korea ysma@etri.re.kr Jeff Offutt Software Engineering George Mason University

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class This homework is to be done individually. You may, of course, ask your fellow classmates for help if you have trouble editing files,

More information

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship.

CSCI 253. Object Oriented Programming (OOP) Overview. George Blankenship 1. Object Oriented Design: Java Review OOP George Blankenship. CSCI 253 Object Oriented Design: Java Review OOP George Blankenship George Blankenship 1 Object Oriented Programming (OOP) OO Principles Abstraction Encapsulation Abstract Data Type (ADT) Implementation

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

Object-Oriented Programming Lecture 2: Classes and Objects

Object-Oriented Programming Lecture 2: Classes and Objects Object-Oriented Programming Lecture 2: Classes and Objects Dr. Lê H!ng Ph"#ng -- Department of Mathematics, Mechanics and Informatics, VNUH July 2012 1 Content Class Object More on class Enum types Package

More information

JAVA - INHERITANCE. extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword.

JAVA - INHERITANCE. extends is the keyword used to inherit the properties of a class. Below given is the syntax of extends keyword. http://www.tutorialspoint.com/java/java_inheritance.htm JAVA - INHERITANCE Copyright tutorialspoint.com Inheritance can be defined as the process where one class acquires the properties methodsandfields

More information

Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

More information

Unit 6. Loop statements

Unit 6. Loop statements Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now

More information

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane.

Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6. Handout 3. Strings and String Class. Input/Output with JOptionPane. Handout 3 cs180 - Programming Fundamentals Spring 15 Page 1 of 6 Handout 3 Strings and String Class. Input/Output with JOptionPane. Strings In Java strings are represented with a class type String. Examples:

More information

In this Chapter you ll learn:

In this Chapter you ll learn: Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

More information

Building Java Programs

Building Java Programs Building Java Programs Chapter 3 Lecture 3-3: Interactive Programs w/ Scanner reading: 3.3-3.4 self-check: #16-19 exercises: #11 videos: Ch. 3 #4 Interactive programs We have written programs that print

More information

Grundlæggende Programmering IT-C, Forår 2001. Written exam in Introductory Programming

Grundlæggende Programmering IT-C, Forår 2001. Written exam in Introductory Programming Written exam in Introductory Programming IT University of Copenhagen, June 11, 2001 English version All materials are permitted during the exam, except computers. The exam questions must be answered in

More information

Computer Programming I

Computer Programming I Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

More information

Explain the relationship between a class and an object. Which is general and which is specific?

Explain the relationship between a class and an object. Which is general and which is specific? A.1.1 What is the Java Virtual Machine? Is it hardware or software? How does its role differ from that of the Java compiler? The Java Virtual Machine (JVM) is software that simulates the execution of a

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Yosemite National Park, California. CSE 114 Computer Science I Inheritance

Yosemite National Park, California. CSE 114 Computer Science I Inheritance Yosemite National Park, California CSE 114 Computer Science I Inheritance Containment A class contains another class if it instantiates an object of that class HAS-A also called aggregation PairOfDice

More information

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4 NOTE: SUN ONE Studio is almost identical with NetBeans. NetBeans is open source and can be downloaded from www.netbeans.org. I

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT BSc (Hons) in Computer Applications, BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems & BSc (Hons) Software Engineering Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT

More information

Inside the Java Virtual Machine

Inside the Java Virtual Machine CS1Bh Practical 2 Inside the Java Virtual Machine This is an individual practical exercise which requires you to submit some files electronically. A system which measures software similarity will be used

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts

Third AP Edition. Object-Oriented Programming and Data Structures. Maria Litvin. Gary Litvin. Phillips Academy, Andover, Massachusetts Third AP Edition Object-Oriented Programming and Data Structures Maria Litvin Phillips Academy, Andover, Massachusetts Gary Litvin Skylight Software, Inc. Skylight Publishing Andover, Massachusetts Skylight

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

CSE 1020 Introduction to Computer Science I A sample nal exam

CSE 1020 Introduction to Computer Science I A sample nal exam 1 1 (8 marks) CSE 1020 Introduction to Computer Science I A sample nal exam For each of the following pairs of objects, determine whether they are related by aggregation or inheritance. Explain your answers.

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Exception Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1

Exception Handling. Overloaded methods Interfaces Inheritance hierarchies Constructors. OOP: Exception Handling 1 Exception Handling Error handling in general Java's exception handling mechanism The catch-or-specify priciple Checked and unchecked exceptions Exceptions impact/usage Overloaded methods Interfaces Inheritance

More information

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities

AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities AP Computer Science A - Syllabus Overview of AP Computer Science A Computer Facilities The classroom is set up like a traditional classroom on the left side of the room. This is where I will conduct my

More information

Introduction: Abstract Data Types and Java Review

Introduction: Abstract Data Types and Java Review Introduction: Abstract Data Types and Java Review Computer Science E-119 Harvard Extension School Fall 2012 David G. Sullivan, Ph.D. Welcome to Computer Science E-119! We will study fundamental data structures.

More information

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A Developed By Brian Weinfeld Course Description: AP Computer

More information

1.1 Your First Program

1.1 Your First Program Why Programming? 1.1 Your First Program Why programming? Need to tell computer what you want it to do. Naive ideal. Natural language instructions. Please simulate the motion of N heavenly bodies, subject

More information

Moving from C++ to VBA

Moving from C++ to VBA Introduction College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 309 Numerical Analysis of Engineering Systems Fall 2014 Number: 15237 Instructor: Larry

More information

Chapter 5 Functions. Introducing Functions

Chapter 5 Functions. Introducing Functions Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name

More information

Smallest Java Package? Java.applet.* having 1 class and 3 interfaces. Applet Class and AppletContext, AppletStub, Audioclip interfaces.

Smallest Java Package? Java.applet.* having 1 class and 3 interfaces. Applet Class and AppletContext, AppletStub, Audioclip interfaces. OBJECTIVES OF JAVA Objects in java cannot contain other objects; they can only have references to other objects. Deletion of objects will be managed by Run time system. An Object can pass a message to

More information

JavaScript: Control Statements I

JavaScript: Control Statements I 1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can

More information

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement CompSci 125 Lecture 08 Chapter 5: Conditional Statements Chapter 4: return Statement Homework Update HW3 Due 9/20 HW4 Due 9/27 Exam-1 10/2 Programming Assignment Update p1: Traffic Applet due Sept 21 (Submit

More information

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html

Install Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install

More information