Docsity

Programs, Data - Object Oriented and GUI Programming - Lecture Slides, Slides of Object Oriented Programming

Partial preview of the text

Download Programs, Data - Object Oriented and GUI Programming - Lecture Slides and more Slides Object Oriented Programming in PDF only on Docsity!

Chapter 2: Programs, Data,

Variables, and Calculations

2

Primitive Data Types

Numerical

  • Byte: (8 bits)
  • Short: (16 bits)
  • Int: (32 bits)
  • long: (64 bits)
  • Float: (32 bits)
  • Double: (64 bits)

4

Other Operators

  • Generally, avoid mixed arithmetic expressions when possible. If you can not, use casting ()
  • Op= operator
  • Bitwise operators (&, |, ~, ^, >>, <<, >>>)
  • Rotate and reversing operations
  • BitwiseOps.java & TryBitMethods.java

5

Mathematical Functions

  • All in Math class that is imported automatically in java.lang package
  • Examples:
    • Math.sqrt()
    • Math.sin()
    • Math.max()
    • Math.round()
  • MathCalc.java

7

Primitive Data Types

Logical

  • boolean: (1 bit)
  • Two constants “true” and “false”
  • Comments “//” or “/* ……………. */”
  • Operator precedence
    • IF in doubt, use parentheses