CS 152 - Lecture 1

Cover page image

Cay S. Horstmann

Course Objectives

Java.* is not the End of History

The “Cambrian Explosion” of Languages

What You Will Learn

What You Need to Succeed

Prerequisites
Time
Laptop

Questions

questions

Plagiarism and Cheating

cheating

Git

Octocat

Adding

Things To Do Today

Lab

lab

Lecture 1 Clicker Question 1

What happens with this code?

List<String> strings = new ArrayList<>(Arrays.asList("Harry", "Sally"));
List<Object> objects = strings;
objects.set(0, new Integer(42));
String first = strings.get(0);
  1. The code compiles and runs without errors
  2. The code throws an exception in line 3
  3. The code throws an exception in line 4
  4. The code doesn't compile

Lecture 1 Clicker Question 2

What happens with this code?

List<String> strings = new ArrayList<>(Arrays.asList("Harry", "Sally"));
List objects = strings;
objects.set(0, new Integer(42));
String first = strings.get(0);
  1. The code compiles and runs without errors
  2. The code throws an exception in line 3
  3. The code throws an exception in line 4
  4. The code doesn't compile

Lecture 1 Clicker Question 3

What happens with this code?

String[] strings = { "Harry", "Sally" };
Object[] objects = strings;
objects[0] = new Integer(42);
String first = strings[0];
  1. The code compiles and runs without errors
  2. The code throws an exception in line 3
  3. The code throws an exception in line 4
  4. The code doesn't compile

Installing Git

Adding to the Repository

  1. In the cs152 subdirectory that was created by git clone, make a subdirectory hw1
  2. In that directory, make a file aboutme.txt as described in Homework 1
  3. Open a terminal and change to the directory into which you cloned the repo:
    cd cs152
    
  4. Type
    git add hw1/aboutme.txt
  5. Type
    git commit -a -m "Started homework 1 "
  6. Type
    git push origin master
  7. In the BitBucket web interface, locate hw1/aboutme.txt
  8. Did you find it? Hooray—you have just reached level 2.

A UML Diagram