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

Difference b/w a static variable and an instance variable?, Class variables...

Class variables are named as static variables. There is only single occurrence of a class variable per JVM per class loader. When a class is operated the class variables are in

La Food Restaurant Program, The fancy new French restaurant La Food is very...

The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of the

Java class, java HW should be written with javadoc comment formatted

java HW should be written with javadoc comment formatted

Program to brute force search, Ask questionWrite a program BruteForceSearch...

Ask questionWrite a program BruteForceSearch that uses the brute-force approach given above and compare its running time on your computer with that of Binary Search for largeW.txt

Explain difference between an if and a switch statement, What is the differ...

What is the difference between an if statement and a switch statement? The if statement is used to select between two alternatives. It uses a boolean expression to decide whi

Mobile android application, Project Description: Overview I am seekin...

Project Description: Overview I am seeking an Oracle ADF mobile app and web service to be created that takes a list of contacts stored on an Android mobile phone or tablet an

Exception handling in EJB, Java has two kinds of exceptions: 1. Checked ...

Java has two kinds of exceptions: 1. Checked exception: handled from java.lang.Exception but not java.lang.RuntimeException. 2. Unchecked exception: handled from java.lang.Ru

How can you performance tune your database?, 1. De normalizes your tables w...

1. De normalizes your tables where required. 2. Proper use of index columns: An index based on numeric parts is more efficient than an index based on character columns. 3. Re

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