Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Where does primitive data comes from  RSS feed

 
Pratik Sinha
Greenhorn
Posts: 11
Firefox Browser Linux Netbeans IDE
  • 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.
 
Tony Docherty
Bartender
Posts: 3268
82
  • 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
Firefox Browser Linux Netbeans IDE
  • 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 ?
 
Paul Clapham
Sheriff
Posts: 22528
43
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"?

 
Jeff Verdegan
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
Firefox Browser Linux Netbeans IDE
  • 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: 3268
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Pratik Sinha: read Jeff's answer.
 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate 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
Firefox Browser Linux Netbeans IDE
  • 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.
 
Henry Wong
author
Sheriff
Posts: 23284
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!