Objects

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Is Int a primitive data type?

Answer:

No—it is not on the list of primitive data types (the word that starts with a small "i" is on the list: int). Remember that Java is case sensitive.

Objects

All data in Java falls into one of two categories: primitive data and objects. There are only eight primitive data types. However, Java has many types of objects, and you can invent as many others as you need. Any data type you invent will be a type of object.

Primitive Data and Objects

Much more will be said about objects in future chapters (since Java is a object oriented programming language). The following is all you need to know, for now:

  • A primitive data value uses a small, fixed number of bytes.
  • There are only eight primitive data types.
  • A programmer can not create new primitive data types.
  • An object is a big block of data. An object may use many bytes of memory.
  • An object usually consists of many internal pieces.
  • The data type of an object is called its class.
  • Many classes are already defined in Java.
  • A programmer can invent new classes to meet the particular needs of a program.

A (crude) analogy is that a primitive data value is like a nut or a bolt, but an object is like a whole machine. If you want to learn more about objects right away, it would not hurt to jump ahead to the Chapter On Objects and read a few pages.

QUESTION 5:

Are numbers of fundamental importance to computer programs?