answersLogoWhite

0


Best Answer

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 object

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 object
User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you explain in which scenario the primitive types are used as objects?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Variables as object in java?

There are two main categories of variables in Java. They are primitive and non primitive. Primitive data types are the basic data types like int, float, char etc. These are not objects. The other non primitive data types are all types of Java Objects. Example: String, ArrayList etc.


What are primitive variables?

Primitive variables are variables that are not objects and carry primitive values like numbers, boolean etc. The primitive data types in java are:intbytefloatcharlongbooleanshortdouble


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).


Why are there both primitive and object versions of integers doubles floats characters and booleans?

Primitive data types like int, float etc are available for us to perform primitive data type operations like addition, subtraction, comparison etc. But since Java is an object oriented language, there are many features in java where such primate data types cannot be used. Only objects can be used. So for using the features of such data types there also we have wrapper classes that would create objects for these primitive data types.


What are entities in c plus plus?

Entities are the objects instantiated by your program, both at compile time and at runtime. Some objects are primitive data types, others are more complex such as objects instantiated from a class.

Related questions

Variables as object in java?

There are two main categories of variables in Java. They are primitive and non primitive. Primitive data types are the basic data types like int, float, char etc. These are not objects. The other non primitive data types are all types of Java Objects. Example: String, ArrayList etc.


What are primitive variables?

Primitive variables are variables that are not objects and carry primitive values like numbers, boolean etc. The primitive data types in java are:intbytefloatcharlongbooleanshortdouble


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).


Why are there both primitive and object versions of integers doubles floats characters and booleans?

Primitive data types like int, float etc are available for us to perform primitive data type operations like addition, subtraction, comparison etc. But since Java is an object oriented language, there are many features in java where such primate data types cannot be used. Only objects can be used. So for using the features of such data types there also we have wrapper classes that would create objects for these primitive data types.


What are object oriented programming language's?

Languages where all types, including primitive types such as integers, are implemented as objects. Java is a pure object oriented language. C++ is not pure because integers, floating point values and pointers are primitive data types that are not implemented as objects. As a result, Java is easier to program, but C++ is more efficient.


What are entities in c plus plus?

Entities are the objects instantiated by your program, both at compile time and at runtime. Some objects are primitive data types, others are more complex such as objects instantiated from a class.


What do you mean by vectors only hold objects not primitive data types?

It means that you can only store values like Integer, String etc in a Vector and not values like int, float etc. int, float, double etc are primitive data types. collections by their default behavior can hold only objects and not primitives.


In c plus plus ....Differences in passing primitive types and objects types?

Primitive types are usually passed be value (many professional programmers use reference or pointers). For object types is always used mechanism pass-by-reference because it allows to save a lot of memory by preventing coping data.


How does java pass primitive types and objects?

Java uses only pass by value. Primitive data types are passed purely as pass by value whereas for objects a value which is the reference to the object is passed. Hence the whole object is not passed but its reference gets passed. All modifications to the object in the method would modify the object in the Heap.


How can you create array of an object in java?

Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.


Data types in c primitive and non primitive?

Primitive types are the data types provided by a programming language as basic building blocks. Primitive types are also known as built-in types or basic types. Depending on the language and its implementation, primitive types may or may not have a one-to-one correspondence with objects in the computer's memory. However, one usually expects operations on primitive types to be the fastest language constructs there are. Integer addition, for example, can be performed as a single machine instruction


Java variables act as object or not?

How a Java variable would act depends on the variable's data type. Variables of the primitive data types like int, char, float etc would not act as objects. But apart from them, all other data types would act as Objects. Almost all data types would extend from java.lang.Object and would behave as objects.