Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review :chapters 1 - 3. What is an algorithm? A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add.

Similar presentations


Presentation on theme: "Review :chapters 1 - 3. What is an algorithm? A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add."— Presentation transcript:

1 Review :chapters 1 - 3

2 What is an algorithm?

3 A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add N1 and N2 and store the result in N4. Now add N4 and N3 and store the result in N4 N4 now contains the sum of all 3 numbers

4 What is the difference between hardware and software?

5 Hardware : Physical and tangible parts of a computer. Eg, CPU, Memory, Graphics card Software : The non-tangible functionality of the computer. Eg, applications, Operating System, programs

6 What is the binary equivalent of the following? 23 42 67 873

7 What is the binary equivalent of the following? 2310111 42101010 671000011 1251111101

8 What is the output of the following? class MyHelloWorldClass { public static void main (String args[]) { System.out.println("Hello " + "World!"); }

9 What is the output of the following? class MyHelloWorldClass { public static void main (String args[]) { System.out.println("Hello " + "World!"); } Hello World!

10 What is the output of the following? class Numbers { public static void main (String args[]) { System.out.println("2 + 3 = " + 2 + 3); }

11 What is the output of the following? class Numbers { public static void main (String args[]) { System.out.println("2 + 3 = " + 2 + 3); } 2 + 3 = 23

12 What is the output of the following? class Numbers{ public static void main (String args[]) { System.out.println("2 + 3 = " + (2 + 3)); }

13 What is the output of the following? class Numbers{ public static void main (String args[]) { System.out.println("2 + 3 = " + (2 + 3)); } 2 + 3 = 5

14 What are the 3 kinds of errors in programming?

15 Syntax error System.out..println(“Hello world!”; Logic errors int num1 = 5; int num2 = num1 + 1; int num3 = 5/num2;-> always gives a 0 Runtime errors String str = “5Long”; System.out.println(str.charAt(5)); int zero = 0; System.out.println(0.9 / zero);

16 What is procedural decomposition?

17 Breaking a bigger problem into smaller, easier to understand and solve parts.

18 What is the output of the following? System.out.println("I am \n using \\/\\/ \t escape sequences \"\" here!");

19 What is the output of the following? System.out.println("I am \n using \\/\\/ \t escape sequences \"\" here!"); I am using \/\/ escape sequences "" here!

20 What is the output of the following? System.out.println("One"); System.out.print("Two"); System.out.print("Three"); System.out.println("Four"); System.out.print("Five");

21 What is the output of the following? System.out.println("One"); System.out.print("Two"); System.out.print("Three"); System.out.println("Four"); System.out.print("Five"); One TwoThreeFour Five

22 What is the output of the following? public static void main (String args[]) { method1(); System.out.println("main"); method2(); } public static void method1() { method2(); System.out.println("method1"); method3(); } public static void method2() { System.out.println("method2"); method3(); } public static void method3() { System.out.println("method3"); }

23 What is the output of the following? public static void main (String args[]) { method1(); System.out.println("main"); method2(); } public static void method1() { method2(); System.out.println("method1"); method3(); } public static void method2() { System.out.println("method2"); method3(); } public static void method3() { System.out.println("method3"); } method2 method3 method1 method3 main method2 method3

24 What are some examples of primitive data types?

25 int boolean char double String and Integer are not primitive data types. They are classes.

26 What is the output of the following System.out.println(1 + 3 * 5 - 5 % 2); System.out.println(1 * 3 * 5 - 5 % 2); System.out.println(1 * 3 * 5 - 5 % 3); System.out.println(1 / 3 * 5 - 5 % 2); System.out.println(1 / 3 * 5 - 5 % 3); System.out.println(1 / 3 * 5 + "+" + 5 % 2);

27 What is the output of the following 1.System.out.println(1 + 3 * 5 - 5 % 2);15 2.System.out.println(1 * 3 * 5 - 5 % 2);14 3.System.out.println(1 * 3 * 5 - 5 % 3);13 4.System.out.println(1 / 3 * 5 - 5 % 2);-1 5.System.out.println(1 / 3 * 5 - 5 % 3);-2 6.System.out.println(1 / 3 * 5 + "+" + 5 % 2);0+1

28 What is the output of the following? for (int i = 0; i < 5; i++) { for (int j = 5 - i; j <= 5; j++) { System.out.print("*"); } System.out.println(); }

29 What is the output of the following? for (int i = 0; i < 5; i++) { for (int j = 5 - i; j <= 5; j++) { System.out.print("*"); } System.out.println(); } * ** *** **** *****

30 Write code Read in an integer from the user. Let’s say the user enters N as the integer. Now print every Nth char in the string “JASS : Just another silly string”. Example Enter the number N for repeating the Nth char 1 JASS : Just another silly string Enter the number N for repeating the Nth char 3 S:u oeslsi

31 Write code Read in an integer from the user. Let’s say the user enters N as the integer. Now print every Nth char in the string “JASS : Just another silly string”. public static void main(String[] args) { String jass = "JASS : Just another silly string"; Scanner input = new Scanner (System.in); System.out.println("Enter the number N for repeating the Nth char"); int n = input.nextInt(); for (int i = 1; (i * n -1) < jass.length(); i++) { System.out.print(jass.charAt(i * n - 1)); } input.close(); }

32 What is the output of the following? String jass = "JASS:JustAnotherSillyString"; System.out.println(jass.length()); System.out.println(jass.substring(2, 5)); System.out.println(jass.substring(3, 7)); System.out.println(jass.substring(0, 0)); System.out.println(jass.substring(10, 15)); System.out.println(jass.substring(15, 21)); System.out.println(jass.substring(25, 27));

33 What is the output of the following? String jass = "JASS:JustAnotherSillyString"; System.out.println(jass.length());// 27 System.out.println(jass.substring(2, 5));// SS: System.out.println(jass.substring(3, 7));// S:Ju System.out.println(jass.substring(0, 0));// System.out.println(jass.substring(10, 15));// nothe System.out.println(jass.substring(15, 21));// rSilly System.out.println(jass.substring(25, 27));// ng

34 What is the output? public static void main(String[] args) { int a = 0; int b = 1; int c = 2; System.out.println(method(method(a, b, c), method(b, a,c), method(c, a, b))); } public static int method(int a, int b, int c) { int returnValue = (int)(Math.pow(a,b) + c); System.out.println(returnValue); return returnValue; }

35 What is the output? public static void main(String[] args) { int a = 0; int b = 1; int c = 2; System.out.println(method(method(a, b, c), method(b, a,c), method(c, a, b))); } public static int method(int a, int b, int c) { int returnValue = (int)(Math.pow(a,b) + c); System.out.println(returnValue); return returnValue; } 2 3 2 10


Download ppt "Review :chapters 1 - 3. What is an algorithm? A step by step description of how to accomplish a task. For example, Adding 3 numbers N1, N2 and N3 Add."

Similar presentations


Ads by Google