Limited time offer 20% OFF StudySoup Subscription details

Georgia Tech - CS 1331 - CS 1331, Week one notes - Class Notes

Created by: Saumya Jain Elite Notetaker

> > > > Georgia Tech - CS 1331 - CS 1331, Week one notes - Class Notes

Georgia Tech - CS 1331 - CS 1331, Week one notes - Class Notes

This preview shows pages 1 - 4 of a 16 page document. to view the rest of the content
background image 1.1­1.10 01/09 Java made in the early 90s by Sun Microsystems Went public in ‘95 An example program
public class Test {
public static void main (String [] args){ System.out.printIn(“A test program”); } } //A comment
/* A longer
comment */ The file name must match the name of class Programming Language Levels Interpreted language (Python)
Interleave, translation & execution
Compiled Language (C)
High level source code, assembly, machine language
Typically source code  machine language (unique to a hardware type)
Java Source Java Compiler  Java bytecode  Bytecode compiler
|            v Java Interpreter Java is system neutral Compiler + interpreter is part of the JAVA SE Development Kit (JDK) IDE – Integrated Development Environment v11 JRE – Java Runtime Environment Syntax + Semantics Java: Object Oriented Language
background image Objects have:
State: Characterized by attributes of object ii. Behaviors: Characterized by methods of object Ex: Car Attributes: color, year, miles Methods: Start the car, drive, brake Class: Model or blueprint from which objects are made. Can make multiple objects from it. Encapsulation: Each object is ultimately responsible for managing its own data Inheritance: Classes form a hierarchy (Children classes get all the info of the main class) 2 01/09 public   class   Example  {      public   static   void   main ( String  []  args ){          int   jan ;         jan =  30  +  1          System . out . println ( "Jan has "  + jan +  "days" );     }
Identifiers 1. Programmer defined. Examples: args, jan 2. Other programmer defined. Examples: System, String, println
3. Reserved Words. Examples: public, class, void
Variables: Case sensitive locations in memory used to hold a data value In java you have to declare the variable, unlike python. (Example: how we used int to define 
int total;
double pi = 3.141;
(can have an initial value)(can change these values later) pi = 6.873; (changes the value of pi) total = 17; total = total + 3; Java is a strongly types language: Cannot assign inappropriate values to variables
total = “xyz”;
Cannot do this since it has been assigned int Declaring constants (These are like variables but value can’t be changed):
background image final int months = 12;
(using the word final finalizes the value)
Once you assign the type to a variable, it can’t be changed Primitive Data Types Integers – byte, short, int, long (8, 16, 32, 64) Floating point numbers – float, double (32, 64) 12: Literal value (can’t be changed) integer literal – int
floating point literal – double
To change:
12L 3.3F 3.3f Characters – char
char literal – ‘a’
‘Q’ ‘!’ char gender = ‘m’; (only a single character) Ascii codes – 8 bits of info (2 8 ) 0  255 Java uses the Unicode instead of Ascii – 16 bits of info (2 16 ) 65,536 chars Boolean – boolean
boolean hot;
boolean easy = true;
Expression Combination of one or more operators or operands
+ ­ * / %
­18 % 4
(­2)(You use the sign of the numerator) 18 / 4 = 4 (integer division) 18/4.0 = 4.5 total = 2 + 3 * 5; Precedence rules: Different levels and some ops are stronger
At same level: left  right
Can force parentheses
1. +­ unary ops
works R  L 2. * / % L  R 3. + ­ L  R 4. = R  L Always use PARENS
Some Operators
Increment Operator : ++ (adds 1 to value)
background image Decrement operator : ­­ (subtracts 1 from value) total ++; (total = total +1) ++ total; (total = total + 1) total = 5; sum = total ++; (the value of sum is figured out first) Here, total becomes 6, sum is 5 total = 5; sum = ++ total
Here, it is pre increment and sum becomes 6
sum += 12; equivalent to sum = sum + 12
result /= a+ b * (c­12)
result = result / a+ b * (c­12) 01/11 There are times when we want to change from one type to another short  long (narrowing) /Won’t work long  short (widening) / OK Three ways to do conversions:
1. Assignments
int sum; double avg;
avg = sum;
(int into double is allowed) sum = avg; (double into int is not allowed) 2. Arithmetic promotion double result; result = sum/avg (Allowed. The int is bumped up to be a double) 3. Casting Using parentheses to transform one type to another sum = (int)avg; (Does truncation) int a = 5, b = 2;
double total;
total = (double)a/b
total = 2.5

This is the end of the preview. Please to view the rest of the content
Join more than 18,000+ college students at Georgia Institute of Technology who use StudySoup to get ahead
School: Georgia Institute of Technology
Department: Computer Science and Engineering
Course: Intro-Object Orient Prog
Professor: John Statsko
Term: Spring 2019
Tags: Java basics
Name: CS 1331, Week one notes
Description: These are the in class notes for the first 3 classes in the first week conducted by John Stasko
Uploaded: 12/30/2018
16 Pages 84 Views 67 Unlocks
  • Better Grades Guarantee
  • 24/7 Homework help
  • Notes, Study Guides, Flashcards + More!
Join StudySoup for FREE
Get Full Access to GATech - Class Notes - Week 1
Join with Email
Already have an account? Login here
Log in to StudySoup
Get Full Access to GATech - Class Notes - Week 1

Forgot password? Reset password here

Reset your password

I don't want to reset my password

Need help? Contact support

Need an Account? Is not associated with an account
Sign up
We're here to help

Having trouble accessing your account? Let us help you, contact support at +1(510) 944-1054 or

Got it, thanks!
Password Reset Request Sent An email has been sent to the email address associated to your account. Follow the link in the email to reset your password. If you're having trouble finding our email please check your spam folder
Got it, thanks!
Already have an Account? Is already in use
Log in
Incorrect Password The password used to log in with this account is incorrect
Try Again

Forgot password? Reset it here