Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to Java
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Lecture Comments (11)

1 answer

Last reply by: Professor Quayle
Thu Apr 27, 2017 10:05 PM

Post by Moksh Modi on April 22, 2017

Hello, Professor Quayle. Really like your slides. I would like to know why did you do  name=n; instead n=name; for both the name field and hobby field.

0 answers

Post by Firebird wang on October 4, 2016

Hi sir, are there any perequiste before review this course? Also, do you know a course called AP Computer Science Principle?

0 answers

Post by Acme Wang on March 9, 2016

Hi Professor Quayle,

When calling an object's method, you say we should use the name of the object followed by a dot, method name and parentheses containing any parameter. But I don't know what is the name of the object?

And what does each mean for this code: Person p = new Person();

Thank you for your time and help.



1 answer

Last reply by: Professor Quayle
Wed May 6, 2015 11:58 PM

Post by Milan Ray on May 6, 2015

I know this doesn't have anything to do with AP Computer Science, but I was wondering what presentation software does use? I don't think its powerpoint or keynote because you can't draw like you do in educator. Is it just photoshop, with the layer as slides?
Milan R.

1 answer

Last reply by: Professor Quayle
Sat Mar 1, 2014 3:09 PM

Post by Avi Sabath on February 23, 2014

Hi Professor Quayle,

When one is creating a class and starts the constructor, is it possible to initialize inside the constructor?

So for example, if I want to initialize private String name to an actual name, would that be possible?

Also, is there an example of when that would be useful, or is it by convention to not do that.

Thanks for the help,

1 answer

Last reply by: Professor Quayle
Mon Dec 24, 2012 5:17 PM

Post by Alex Moon on December 9, 2012

Hi, I extended the example for static vs instance so that the program asks whether you want to recommend more members. NOTE: I changed variable name into "public static String name"

name = sc.nextLine();

System.out.println( name+" has been admitted to our club!");
System.out.println("Would you like to recommend another member? (y/n)");

String decision = sc.nextLine();

if ( decision ="y")
while (decision ="y")
// etc

Everything is fine until I keep getting an error with < if ( decision ="y") > that says "String cannot be converted into boolean"

I can't get it to work, and it keeps bugging me. Im not trying to make a boolean, just have the program check if the user answered "y" or "n".

Thank you!

0 answers

Post by Professor Needham on June 21, 2012


27:59 Example: Static vs. Instance (slide)
Third line from the bottom should read "cm1" not "cm"

44:19 Overloaded Methods (slide)
Last line should read "be" not "by"

Classes & Objects

  • A Java program consists of classes
  • A constructor creates a new object of a class
  • A method is a function defined within a class
  • A class can also contain data fields
  • The return type is the type of value that a method returns to the caller
  • Public: everyone outside the class can get at the method or data
  • Private: only members of the class can get at the method or data
  • Instance: each object of the class gets its own copy of the method or data
  • Static: the method or data is shared by the class instead of multiple copies
  • Overloaded methods are two or more methods with the same name but different signatures

Classes & Objects

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Roadmap 0:46
  • Classes and Objects 2:03
    • Class
    • Object
  • Constructors 3:43
  • Constructors 5:34
  • Methods 7:11
    • Example: getName Method
  • Methods 8:45
    • Example
    • Example in Java Program
  • Data Fields 12:48
    • Way to Find Data Fields
  • Data Fields 13:50
    • Example: Instantiate Two Objects with Different Instance Data
  • Return Type 16:21
    • A Primitive Type
    • An Object of a Class Type
  • Return Type 17:25
  • Access Control 18:19
    • Public, Protected and Private
    • Assumptions Made in AP Java Subset
  • Access Control 20:58
    • Definition of Public
    • Definition of Protected
    • Definition of Private
    • Guidelines on What to Make Public/ Private
  • Accessors and Modifiers 24:47
    • Accessor
    • Modifier or Mutator
  • Static vs. Instance 27:15
    • Static Member
  • Example: Static vs. Instance 27:59
    • Code Example
  • Passing Data to Method 34:00
    • Code Example
  • Getting Data Back From Methods 37:28
    • To Make Use of a Return Value
    • Code Example
  • Overloaded Methods 39:39
    • Signature Includes
    • Signature Does Not Include
  • Example: Overloaded Methods 43:52
  • Overloaded Methods 44:19
  • Summary 45:00