CSE 1020: Introduction to Computer Science I Mark Shtern
Course Objective Developing development skills Writing Java Multiclass application Introducing the software engineering concern Study UML, OOP, API
Example 01 Write application that calculates rectangle area
Example 02 Write application that calculates volume of rectangle couboid
Math & Computers Algebraic laws (a*b) /c is equal to a * (b/c)
Ex 1.16 What is program output? char grade= ‘B’; System.out.print(grade); { grade = ‘C’; } System.out.println(grade);
Ex 1.17 Explain the compile-time error long speed = 1; int size = 7; { boolean even = false; long speed = 5; size = 2; } int even = 3; System.out.println(speed); System.out.println(size); System.out.println(even);
Ex 1.17 What is output? long speed = 1; int size = 7; { boolean even = false; size = 2; } int even = 3; System.out.println(speed); System.out.println(size); System.out.println(even);
Summary Types Declaration Arithmetic Operations Casting Scope +,-,/,* ,% (remainder) Casting Scope
Shortcuts a++ a=a+1 a-- a=a-1 a+=6 a=a+6 a*=6 a=a*6
Literal Real Boolean Character 7D or 7d 7 is double 2.5E 3 2.5*10^3 or 2500.0 Boolean true or false Character ‘\t’ , ‘\n’, \’, ‘\\’,’\”’
Program Execution Edit Compile Run
Java Program Byte code Compile-time Errors VM CPU Byte code javac java instruction
Ex 1.18 Is it true that expression a * b * c/d (1) is evaluated as
Ex 1.21 Explain the compile-time error int i = 6; long l = 4; double d = 12; l = i + i; d = i + i; i = l + l; l = d + d;
Ex 1.22 Explain the compile-time error or predict its output int x = 3; int y = 14; double pie = x + y / 100.0; int z = (5 % 4) + 6 / 8; System.out.println (pie); System.out.println(z);
Math & Computer sqrt(x^2) vs (sqrt(x))^2 (1/x) * x vs x * 1/x
Char Type What is output? char letter = ‘D’; letter = (char) (letter +1); System.out.println(letter); ------------------------------------------ char letter2 = ‘A’; System.out.println(letter2 - letter);