Logout

D.3.4

Describe the uses of the primitive data types and the reference class string.

 

Teaching Note:

In examination questions the primitive types will be limited to int, long, double, char and Boolean.

MYP Mathematics: forms of numbers.


 

Sample Question:

sdfsdfsf

JSR Notes:

Firstly trying to figure out how to interpret the assessment statement and teaching note: Let's assume this is saying "describe the use of" int, long, double, char, boolean, and String. And that it's not so concerned about the fact that String is a class, but can also be used as a literal type, like primitives.

So it's simply, "describe the use of int", with an answer that is really basic, but that someone walking down the street would not be able to answer.

So: int: int is used to represent medium length integer values.

Here are the others:

long: long is a data type used to represent very large integer values.

double: double is a data type which is used to represent real number values, i.e. those with decimals.

char: char is a data type used to represent individual characters, in fact, those characters represented in the ASCII table, such as 'a', 'A', '2', and '!'.

boolean: boolean is a data type used to represent either true or false, and that's it.

string: string is a data type used to represent a string of characters; i.e. words. (Again, regardless of whether String is being treated as a literal, or a reference type.)

 

 

But, if you want to look at how String is kinda weird, in that it can be treated as a literal or a reference type, here are some notes:

780     notes  Strings as Objects vs Literals, & String Equality vs Identity 
782 diagram (Rated Epic)
783 diagram (Rated Basic) (& deja vu)

Something tells me I have better, more succinct notes somewhere too, but the point here is that String can be treated as a primitive, but can also be treated as a "reference class", when we call the constructor of String, using the new operator.

So, as mentioned lots of places in these notes and the Java Revolution, primitives are literally their value in memory where their variable is a short-cut for. But String as a "reference class" is an object, i.e. an address reference to where the String object, along with it's char array, and its String attributes and methods, such as length reside.