1. What is a data type?: answer- What kind of data that a value represents
- It is either specified by the programmer or by the rules of the
programming language
- every piece of data has an unambiguous type
- there are two kinds of types in Java: primitive and non-primitive
2. What is a typecast? How is it different for when typecasting objects?What
things are similar?: answer- - Typecasting a primitive type converts a
value of one type into a value of a different type
- Typecasting a non-primitive type changes how you can use that
variable, but it does not change the location in memory
- Typecasting a non-primitive type means that the methods and fields
you can access change depending on what you have typecasted to
- The way in which you typecast is the same
- For compound types, automatic typecasting occurs when you go from
a lower to a higher place in the hierarchy; for primitive types, it is
,automatic when you go from a narrower type to a wider type
3. You can typecast (convert) between all primitive types except .: boolea
4. T/F: You cannot typecast between primitive and compound types: T
5. How do you typecast?: - you place the desired type in parentheses and
imme- diately to the left of the value(desired-type)value
6. When are typecasts done automatically?: Values are automatically
converted from narrower to wider types
7. When must a typecast be explicit?: When you are converting from a
"wider" type to a "narrower" type
8. List the primitive types in Java from widest to narrowest: 1. double
2. float
3. long
4. int
5. short/char
6. byte
9. Generally, when converting to a wider type, Java converts the value to as
as possible to the original value.When converting to a narrower
type, Java generally the value.: - close
- truncates
,10.What is a primitive type? How many primitive types are there in Java?:
- types already predefined in Java
-8
1. int
2. double
, 3. float
4. long
5. short
6. boolean
7. char
8. byte
11.What is a non-primitive/compound type in Java?: A type that is both
pre-de- fined and programmer defined; It can be made of primitive
types and other com- pound types
12.What are the differences between primitive and compound types?: -
prim- itive types:
1. the value of the type is the binary representation of the value
2.There are specifically 8 of them and they are pre-defined in Java
- compound:
1. the value of the type is the location of the instance in memory
2.There are an endless amount and can be either pre-defined or
programmer-de- fined
3.A basic compound type is called a class, which consists of variables of
any type, methods that take 0 or more inputs + possibly perform some
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Labsolution. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $8.99. You're not tied to anything after your purchase.