answersLogoWhite

0


Best Answer

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

I'll use my knowledge of Java; the situation might be a bit different in other languages.

  • Primitive data types are the basic building blocks. Class data types join primitive (and other class) data types together to build larger building blocks.
  • Primitive data types (if defined by themselves in a method) are stored in the stack. Objects (based on classes) are stored in the heap.
  • As a result, primitive variables are destroyed as soon as the method that creates them finishes running.
  • Objects, on the other hand, are not destroyed as long as some variable references them. Once no variable references them, the garbage collector will reclaim the space they are using up... at some later time.
This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Primitive data types are the most basic types of information storage available in programming languages. Classes are essentially just collections of many primitive types and the functions which perform operations on them.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Using Wrapper class we create objects ..whereas using primitive data type we create variable which are not object...

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are the Difference between primitive data types and wrapper classes?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is type wrappers in java?

A wrapper class in the Java programming language is one of eight classes provided in the java.lang package to create objects for the eight primitive types. All of the primitive wrapper classes in Java are immutable. Wrapper classes are used to represent primitive values when an Object is required. The wrapper classes are used extensively with Collection classes in the java.util package and with the classes in the java.lang.reflect reflection package. The Wrapper classes are: 1. Byte 2. Short 3. Integer 4. Long 5. Float 6. Double 7. Character 8. Boolean The Byte, Short, Integer, Long, Float and Double are all subclasses of the Number class. If you notice, the names of these wrapper classes are just the same as their primitive data type with a capitalized first letter. These wrapper classes start with a upper case alphabet while their primitive counterparts start with a lowercase alphabet.


What are object wrappers?

Wrapper classes are classes that are used to make primitive variables into objects, and to make wrapped objects into primitives. int, boolean, double are all primitive data types and their respective wrapper classes are Integer, Boolean, and Double. Wrapper classes are useful in storing primitive data types in higher level data structures such as Stack<Object>, List<Object>, Queue<Object>, since primitives cannot be directly placed in these data structures they must be boxed in the wrapper classes. But, here's the good news, with the new Java 5.0, there is no need no worry about wrapper classes and boxing and unboxing (unless it's something taught in class), since there is auto-boxing and unboxing, therefore, one can directly "add" primitives to a data structure and let the JVM do the rest.


What is wrapper class and its use?

When we need to store primitive datatypes(The data types we use in genera like:int,long,float etc)as objects, we use wrapper classes.Means in utility classes all the utility classes stores Objects.So when we need to store a primitive datatype,We make an object of that primitive data and store it. Say supposing there is a requirement to store only the object in an array A.The Primitive types cannot be stored in the same array as the array can accommodate only Objects here is where Wrapper Class come into picture.ie, we create wrapper for the primitive types.One such example is as below Ex:int i; Wrapper class for the primitive type(int) is created as below: Integer i = new Integer(); That's why we use Wrapper classes in Java


Can you explain in which scenario the primitive types are used as objects?

It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an objectIt is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object


Are Wrapper classes immutable or mutable?

In java.lang all Wrapper classes are immutable .

Related questions

What is type wrappers in java?

A wrapper class in the Java programming language is one of eight classes provided in the java.lang package to create objects for the eight primitive types. All of the primitive wrapper classes in Java are immutable. Wrapper classes are used to represent primitive values when an Object is required. The wrapper classes are used extensively with Collection classes in the java.util package and with the classes in the java.lang.reflect reflection package. The Wrapper classes are: 1. Byte 2. Short 3. Integer 4. Long 5. Float 6. Double 7. Character 8. Boolean The Byte, Short, Integer, Long, Float and Double are all subclasses of the Number class. If you notice, the names of these wrapper classes are just the same as their primitive data type with a capitalized first letter. These wrapper classes start with a upper case alphabet while their primitive counterparts start with a lowercase alphabet.


What is meant by wrapper classes?

Java has several "primitive" types (byte, short, int, float, double, boolean, char). Wrapper classes refer to the classes which "wrap up" each of these. For example, the Byte class contains a byte primitive and the methods to modify the class.


What are object wrappers?

Wrapper classes are classes that are used to make primitive variables into objects, and to make wrapped objects into primitives. int, boolean, double are all primitive data types and their respective wrapper classes are Integer, Boolean, and Double. Wrapper classes are useful in storing primitive data types in higher level data structures such as Stack<Object>, List<Object>, Queue<Object>, since primitives cannot be directly placed in these data structures they must be boxed in the wrapper classes. But, here's the good news, with the new Java 5.0, there is no need no worry about wrapper classes and boxing and unboxing (unless it's something taught in class), since there is auto-boxing and unboxing, therefore, one can directly "add" primitives to a data structure and let the JVM do the rest.


What is wrapper class and its use?

When we need to store primitive datatypes(The data types we use in genera like:int,long,float etc)as objects, we use wrapper classes.Means in utility classes all the utility classes stores Objects.So when we need to store a primitive datatype,We make an object of that primitive data and store it. Say supposing there is a requirement to store only the object in an array A.The Primitive types cannot be stored in the same array as the array can accommodate only Objects here is where Wrapper Class come into picture.ie, we create wrapper for the primitive types.One such example is as below Ex:int i; Wrapper class for the primitive type(int) is created as below: Integer i = new Integer(); That's why we use Wrapper classes in Java


Can you explain in which scenario the primitive types are used as objects?

It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an objectIt is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object


Are Wrapper classes immutable or mutable?

In java.lang all Wrapper classes are immutable .


Do the primitive datatypes in java have objects?

No Primitive data types do not have objects. As of Java 1.5, all primitive types in Java have "wrapper" classes. These classes serve two purposes: # They keep all type-specific methods together in one place. # They allow primitive types to be used in situations which take advantage of generics (also introduced in Java 1.5).


What is the difference between Halloween and Christmas candy?

the wrapper


Java program to illustrate Wrapper class?

java uses simple or primitive data types, such as int, char and Boolean etc. These data types are not part of the object hierarchy. They are passed by value to methods and cannot be directly passed by reference. However, at times there is a need to create an object representation of these simple data types. To address this need, Java provides classes that correspond to each of these simple types. These classes encapsulate, or wrap, the simple data type within a class. Thus, they are commonly referred to as wrapper classes. Wrapper classes corresponding to respective simple data types are as given in table below. Primitive Data Types Wrapper class byte Byte short Short int Integer long Long char Character float Float double Double boolean Boolean void Void eg Say supposing there is a requirement to store only the object in an array A.The Primitive types cannot be stored in the same array as the array can accommodate only Objects here is where Wrapper Class come into picture.ie, we create wrapper for the primitive types.One such example is as below Ex:int i; Wrapper class for the primitive type(int) is created as below: Integer i = new Integer();


What are primitive date types and their wrapper classes?

every primitive datatype has its own warpper class in java every command line arguement is considered as array in this we have + operater which is an concatination and if we wnt to add them we can get the expected result for 2+2 it gives 22 but its ans is 4 in such a case we have go for Integer which is wrapper class to int and so we can get the expected result


What is wrapper class in java?

wrapper class is a predefined class .it is used for converting primitive data types into object type


What are the functions and variables of all the wrapper classes and their uses?

Wrapper classes wrap primitive types (eg: int, double, etc) in Objects which can be placed into Vectors, and many, many other uses. *Notice that an Object starts with a capital letter, while the primitives all start with a lowercase.Also notice that Strings are Ojects. These Wrapper classes can be created in many ways, so i will start slow, simply returning objects with a String. Ex: Integer from String: Integer i = Integer.valueOf("125");