Abhay Bhatt

Ranch Hand
+ Follow
since Jun 30, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
2
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
55
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Abhay Bhatt

Stephan van Hulst wrote:

Car manufacturers must publish modules that contain the declarations of the methods that can be called, otherwise guidance manufacturers can't develop their software effectively. However, they are not required to publish the modules that implement these methods. They could install these modules right into the cars that they manufacture, even having them protected by the car's hardware. When they don't use interfaces to publish the method declarations, they must include their implementations with the published module, which can then be reverse engineered by the guidance manufacturers.



Can you please tell me what do you mean by a 'published module'? My best guess would be that it might have something to do with access modifiers but then I am not sure.

Stephan van Hulst wrote:

Yes, you could say that. However, usually default method implementations shouldn't be very complex, so I doubt anybody would care about reverse engineering them.



But they can be complex, can't they? Is there a logic behind, functionality added later on, being, usually or always, relatively less complex or simpler, in nature?
6 years ago
I am new to Java and never done a full blown project, so may be my question is very silly and answer very obvious   , but I will throw it anyway:-

I read in the oracle docs that interfaces help in keeping the secrecy of code/implementation, ie they prevent your code/implementation from being exposed to the other party. Below is an excerpt from oracle docs:-



For example, imagine a futuristic society where computer-controlled robotic cars transport passengers through city streets without a human operator. Automobile manufacturers write software (Java, of course) that operates the automobile—stop, start, accelerate, turn left, and so forth. Another industrial group, electronic guidance instrument manufacturers, make computer systems that receive GPS (Global Positioning System) position data and wireless transmission of traffic conditions and use that information to drive the car.

The auto manufacturers must publish an industry-standard interface that spells out in detail what methods can be invoked to make the car move (any car, from any manufacturer). The guidance manufacturers can then write software that invokes the methods described in the interface to command the car. Neither industrial group needs to know how the other group's software is implemented. In fact, each group considers its software highly proprietary and reserves the right to modify it at any time, as long as it continues to adhere to the published interface.\



My simple question is that how, in the case where we don't create/use any interface, the code of auto manufacturers and guidance manufacturers gets exposed to each other(which creates the need of an Interface in the first place)? I mean, even when you implement an Interface, its not that the code of auto manufacturers is in a server in USA and the code of guidance manufacturers is in India, with both servers not connected by any network!!

My second question is regarding default methods. Suppose, in the above example, auto manufacturers implement an default method in the interface itself, so now does that default method code/implementation gets exposed to guidance manufacturers? If yes, then is using default methods, a trade off? Ie you gain something(adding new methods conveniently to old interface) but you also loose something(hiding your implementation)?

6 years ago

Knute Snortum wrote:
If you just write Class clazz you get a compiler warning, because the compiler doesn't know what type (generic type) of Class you mean.  



Thanks a lot! I really appreciate, this explanation is the most lucid/clear/good I've encountered to a question which I asked, since a long time!

Regarding above quoted statement, doesn't compiler know already what the 'type' is, since 'Class' is a class and therefore a 'type'? Why is this need to know this 'generic type' w.r.t. the 'Class'?
6 years ago

Henry Wong wrote:

Second, the type being referred to here is the generic, and not the type of the object... but yes, you are declaring a reference to a Class instance, whose generic can be any type

Henry



I think may be I am going a bit too out of focus here, when its not necessary. Can you please tell me if this 'generic type' thing you mentioned above is applicable for and ? Because I was only concerned with these two originally.
6 years ago

Henry Wong wrote:

First of all, you are declaring a reference, and not the object.



Do you mean a reference to an object by the term 'reference' here?

Henry Wong wrote:

Wildcards are for the reference only, and not related to the object.



Can you please elaborate?

Henry Wong wrote:

Second, the type being referred to here is the generic



I am unable to understand what 'generic' means. Can you please explain?
6 years ago

paul wheaton wrote:Here is the full and complete reason:   there was some disagreement among the staff about what the algorithm should be like.   I felt like it is possible to come up with an algorithm that would make everybody on the staff happy, but it would be a pretty rich algorithm.  So I locked down all the editing until we can have a great solution.  The first step would be that somebody would need to take the time to make a proposal that everybody would be happy with.  It would probably be default settings for the whole site, with some fine tuning by certain forums, and further fine tuning by thread or post or user.  

That was over a year ago.

So far, nobody has made a proposal.



But why there is a need for an algorithm/restriction in the first place?
6 years ago
I don't know/understand what possibly could be the reason behind placing 'Editing' restrictions ie "One can only edit his/her posts, if he/she has more than some number of cows".

Some one suggested me to request some other, to edit my post, when required. This is more inconvenience than what seems.

If there is some genuine reason, atleast can it be allowed for first few minutes after posting, because most edit requirements are there in that time frame?
6 years ago

Ron McLeod wrote:You had an extra [quote] tag in your post - I removed it for you.



Is it possible that I have some quote tags which are not accounted for, when submitting the comment? Because I clearly remember that there was no quote tag after my statement/comment ended.
6 years ago
As per my readings/understandings:-

Every time JVM creates an object, it also creates a java.lang.Class object that describes the type of the object. All instances of the same class share the same Class object.

Class<SomeClass> is a way to represent this object, which is of type Class and was created when any object of type 'SomeClass' class was created(as per above definition) and also, is associated with 'SomeClass' class.

But when I read below StackOverflow thread, regarding Class<?>:-

https://stackoverflow.com/questions/9921676/what-does-class-mean-in-java

it is said in the very first answer that by writing Class<?>, we're declaring a Class object which can be of any type. I am so confused, wouldn't this object be of type Class regardless of what '?' is, since its an object of class Class?
6 years ago
See the below post:-

https://coderanch.com/t/683821/java/Unable-find-current-package

The later comments by me at the very below, are created by quoting other comments(by Norm Radder). The problem is that my whole comment is colored in 'white' instead of just the quoted portion. And I am very sure that the '' term was at the appropriate place, when I submitted my comment.

6 years ago

Norm Radder wrote:
You need to study about classes and methods.  See the tutorial:


I am really sorry. Its my bad! I misunderstood some code statements in another article. My question is originally wrong.
6 years ago

Norm Radder wrote:

 You need a reference to an instance of the class to be able to call its methods:


Where does your code have a reference to an instance of the Package class so that it can call its getPackage method?



I am so much confused regarding how to use in-built methods and packages. May be I didn't gave this a thought recently! I can understand that you may need the instance of the class to call its method. But, if I create an instance of the Package class, I will get the package name of that class, whereas I want to know the package name of my current class ie Hello. I may be getting you wrong, but if what you say is true, then no one will be able to use these in-built methods for their own purpose.

6 years ago

Norm Radder wrote:
You need to look at the API doc for the class that method is in to see how to use it.



So, I looked it and found that getPackage() belongs to java.lang package. So, I imported this package by: import java.lang.*;

But I am still getting the same error message. Any idea as to why the compiler is unable to find the method 'getPackage()'?
6 years ago

Norm Radder wrote:  Hello.getPackage()
is the syntax for calling the static method in the class Hello.  The compiler gives an error message because it can not find that method.



Can you please elaborate on above? So, how one is suppose to use this method to know the package name, ordinarily?

Norm Radder wrote:
Sorry I do not see it shown in your post.  I was looking for something like this:   A command-line that executes the java command with Hello
C:\MyFolder\>java Hello
showing the java command with one argument: Hello



Sorry, I thought you were asking for the output. Here you go:-

D:\Manu\Study>java Hello
6 years ago