• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Where does primitive data comes from

 
Greenhorn
Posts: 11
Netbeans IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a java class just by specifying int, float, double etc. we are using it directly. But my question is how the compiler or jdk is providing it. Where does it comes from ?

For example, when we are writing we know that System class is present in the java.lang package and is by default available and it uses PrintStream object's println method for output.

Hope I can made myself clear.

Please reply.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are part of the Java language definition. You could equally say when I use an 'if' statement where does 'if' come from.
 
Pratik Sinha
Greenhorn
Posts: 11
Netbeans IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tony Docherty wrote:They are part of the Java language definition. You could equally say when I use an 'if' statement where does 'if' come from.



Exactly but I was asked this question in an interview and I was stumped !!
What should be my reply ?
Do I need to know about JVM architecture ?
 
Sheriff
Posts: 24633
56
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My response to that question would be

What do you mean by "come from"?


 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pratik Sinha wrote:

Tony Docherty wrote:They are part of the Java language definition. You could equally say when I use an 'if' statement where does 'if' come from.



Exactly but I was asked this question in an interview and I was stumped !!
What should be my reply ?
Do I need to know about JVM architecture ?



The language spec and JVM spec define what primitive data types are and how they behave. All that matters is that compiler implementers and JVM implementers follow those rules. How they do it is immaterial.

Ultimately, Java's int type and operations get mappe to some type and operations in whatever language the JVM is written in. For someone writing Java code, the details of that mapping don't matter. All that matters is that the end result behaves as the JLS defines it.

And I second what Paul says: What do you mean by "come from"?
 
Pratik Sinha
Greenhorn
Posts: 11
Netbeans IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks @ Paul Clapham for your quick reply really appreciate it. What I meant was if we are declaring primitive data types they are made available to use but by whom?

My response to that question would be

What do you mean by "come from"?

 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Pratik Sinha: read Jeff's answer.
 
Bartender
Posts: 10777
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pratik Sinha wrote:What I meant was if we are declaring primitive data types they are made available to use but by whom?


I suspect you mean "by what", and that will depend entirely on which access modifier you use when you declare the value.

Winston
 
Pratik Sinha
Greenhorn
Posts: 11
Netbeans IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Tony Docherty @ Jeff Verdegan and @ Winston Gutkowski

The language spec and JVM spec define what primitive data types are and how they behave. All that matters is that compiler implementers and JVM implementers follow those rules. How they do it is immaterial.

Ultimately, Java's int type and operations get mappe to some type and operations in whatever language the JVM is written in. For someone writing Java code, the details of that mapping don't matter. All that matters is that the end result behaves as the JLS defines it.

And I second what Paul says: What do you mean by "come from"?



I suspect you mean "by what", and that will depend entirely on which access modifier you use when you declare the value.

Winston



@Pratik Sinha: read Jeff's answer.



Really appreciate your helpful comments. What i figured out from all of your replies that I should only be concerned with the usage and not on how the compiler is using or providing it. I don't know much about Java so forgive me for all my stupid questions.
 
author
Posts: 23838
141
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Pratik Sinha wrote:@ Tony Docherty @ Jeff Verdegan and @ Winston Gutkowski

Really appreciate your helpful comments. What i figured out from all of your replies that I should only be concerned with the usage and not on how the compiler is using or providing it. I don't know much about Java so forgive me for all my stupid questions.




There is nothing wrong with stupid questions. After all, if you don't ask it, how are you going to learn?

However....

Pratik Sinha wrote:
Exactly but I was asked this question in an interview and I was stumped !!



Doing it via trial by fire in a job interview is really not recommended. There are much better ways to figure out what to learn.

Henry
 
permaculture is largely about replacing oil with people. And one tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!