Differentiate between primitives and objects, JAVA Programming

Assignment Help:

Differentiate between Primitives and Objects

  • Everything in Java is an "Object", as every class by default inherits from class

"Object", except a few primitive data types, which are there for efficiency reasons.

  • Primitive Data Types

Primitive Data types of java

boolean, byte                1 byte

char, short                   2 bytes

int, float                      4 bytes

long, double                 8 bytes

  • Primitive data types are normally used for local variables, parameters and instance variables (properties of an object)
  • Primitive datatype are located on stack and we can only access their value whereas objects are located on heap and we have a reference to these objects
  • Additionally primitive data types are always passed by value while objects are always passed by reference in java. There is no C++ like methods

- void someMethod (int &a, int & b) // not available in java

 


Related Discussions:- Differentiate between primitives and objects

Explain operator precedence in java, Explain operator precedence in java ? ...

Explain operator precedence in java ? It's probable to combine multiple arithmetic expressions in one statement. For example the subsequent line adds the numbers one by five:

Online Music Store, Online music store that stores information about song, ...

Online music store that stores information about song, artist, album, customer, playlist. Also all necessary diagrams - use case, uml, erd

Java, Ask question Write an inheritance hierarchy for classes Quadrilateral...

Ask question Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Create

#The ArrayList class java, i want a full program with test about the follow...

i want a full program with test about the following: linkedComputers: We will assume that a number of methods are required. These are specified below. String getComputerName() ret

Write a parser, I have a parser. it is written in Java. I need to add a has...

I have a parser. it is written in Java. I need to add a hash table to it. I am wondering about if you can do it.

Use the constructor, Can we use the constructor, instead of init(), to init...

Can we use the constructor, instead of init(), to initialize servlet? Ans) Yes. Of course you can use the constructor instead of init(). There's nothing to stop you. But you sho

How to retrieve warnings, SQLWarning objects are a subclass of SQLException...

SQLWarning objects are a subclass of SQLException that deal with database access warnings. Warnings do not stop the implementation of an application, as exceptions do; they easily

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd