GeekInterview.com
Series: Subject: Topic:
Question: 314 of 577

Why String is not a primitive data type

Asked by: gothlururaaja | Member Since Oct-2005 | Asked on: Jun 23rd, 2006

View all questions by gothlururaaja

Showing Answers 1 - 14 of 14 Answers
Musarath

Answered On : Jun 24th, 2006

The primitive datatypes are nothing but the basic data types..like int,char,float,double etc..Char is a datatype which stores 2 bits of data..String has been derived from Char which takes more number of Char and integers..providing the more memory storage...Its not a primitive coz it is a basic datatype...Its advancement of char..So its not a primitive datatype

  
Login to rate this answer.
babjiblaji

Answered On : Jun 26th, 2006

View all answers by babjiblaji

then how double is a primitive data type its also derived for float so pls clarify

  
Login to rate this answer.
bhargavi

Answered On : Jun 27th, 2006

As balaji has asked a nice question that " why double is a primitive data type as it came from float?" As double is the default data type given to the floating point-numbers.Naturally when we declare float f =0;---------the memory occupied to it is double.Inorder to use memory effectively,we go for float as float f=0.0f;As double is not a two float.

  
Login to rate this answer.
Guest

Answered On : Jun 29th, 2006

There are two types of datatype 1. primitive 2. ObjectI think String can also be primitive and Object type.If u write String a = "rabbi"; then the String will be used as primitive datatype.But If u write String a = new String("rabbi"); then String will be used by Object datatype.

  
Login to rate this answer.
Suri

Answered On : Jul 1st, 2006

I think both:String a= "abc"; and String a = new String("abc");are the same.

  
Login to rate this answer.
rabbi

Answered On : Jul 2nd, 2006

View all answers by rabbi

You r right Suri Strings are immutable , so String a = "abc"; is same as String a = new String("abc");

  
Login to rate this answer.
babjiblaji

Answered On : Jul 3rd, 2006

View all answers by babjiblaji

yes u r right surithank u

  
Login to rate this answer.
Ananth Murthy

Answered On : Jul 4th, 2006

Float and double both occupy fixed amount of memory irrespective of what number it holds. But String is an object. Memory allocation depends on the content

Yes  1 User has rated as useful.
  
Login to rate this answer.
babjiblaji

Answered On : Jul 4th, 2006

View all answers by babjiblaji

Ok thanks

  
Login to rate this answer.
Amit

Answered On : Jul 18th, 2006

The Main reason behind is that when we talk about primitive data typeLets say for ex int i=5 , it means in memory where we have i , if we will access the contents there we will get the value 5.But in case of a String , when we say String s="abe";when we try to access the contents of s we get the address where we have "abc".

Yes  1 User has rated as useful.
  
Login to rate this answer.
sravani

Answered On : Jul 26th, 2006

String is a predefined class and it is not a data type

  
Login to rate this answer.
balaji

Answered On : Jul 26th, 2006

hi .. thank for ur replynow its clear bye keep smiling and mailing

  
Login to rate this answer.
Videh Jaiswal

Answered On : Feb 23rd, 2009

View all answers by Videh Jaiswal

String is not a primitive data type becoz string is a class . Java programmers made it class in java application as java.lang package.

  
Login to rate this answer.

String is not a primitive data type.It is a wraper class which wraps up type called char.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.