To Lecture Notes

IT 313 -- Jan 6, 2020

Is IT 313 the Right Course for You?

Course Website

Review Quiz

  1. What are these datatypes?
         integer   floating point   character   string   boolean
    Ans: Here is a table showing the Python and Java primitive datatypes. The numbers in parentheses are the number of bytes needed to represent that datatype in the Java Virtual Machine.

    Meaning Python Java
    Integer int (unlimited) byte (1) short (2)
    int (4) long (8)
    Floating Point float (8) float (4) double (8)
    Character   char (2)
    Character String str (4 or 8 byte
    reference variable)
    String (4 or 8 byte
    reference variable)
    Logical bool (1) boolean (1)

    An integer value is a whole number: positive, negative, or zero. For example: 834564, -5348372, or 0.
    By default, Java int variables are between -2 billion and 2 billion.
    A floating point value is a number with a decimal point and optional exponent. E.g.: 5.342, -6.3372, 0.0, 3.4356e11 (means 3.456 × 1011).
    A character constant is a single unicode character. E.g.: 'W', '5', '$'. We will see how to represent non-keyboard unicode characters later.
    Strictly speaking, Java can only deal with 2-byte Unicode characters. Chinese has so many characters, that 4 bytes are needed to represent all of them.
    Java character constants always use single quotes.
    A string constant is a sequence of zero or more characters: "dog", "elephant", "12345", "!@#$%^&*()", "" (empty string).
    A boolean constant is either true or false.
  2. List the Python operators that you know. Most of these also work as Java operators. Ans:
    Arithmetic: +  -  *  /  %
    
    String Concatenation: +
    
    Comparison: <  >  <=  >=  ==  !=
    
    Logical: &&  ||  ^  !
    
    Bitwise: &  |  ^  ~
    
    Assignment: ++  --  +=  -=  *=  
                /=  %=  &=  |=  ^=  
    
    Array Lookup:  [ ]
    
    Grouping, Function Invocation:  ( )
    
    Tertiary Conditional Operator:  ?
    
    Member Access:  .
    
    The ? operator is also called the Elvis operator, because it looks like Elvis Presley's hair when turned sideways.
    See Horstman, page 866 for an operator precedence table.
  3. Name some common control structures. Ans:
    Python: if..else, if..elif..else, while, for.
    Java: if..else, if..else if..else, switch, while, do..while, for.
  4. Give some plausable examples of objects in the sense of object oriented programming. Ans:
    Person  Student  Pet  BasketballPlayer  Transaction  CatalogItem  Automobile
    

Working with Java

The HelloWorld Example

Standard IO

Redirection

Some Windows and Unix Shell Commands

IntelliJ Editor

Project 1