Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Utha Ramadhan

Greenhorn
+ Follow
since Jul 18, 2013
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Utha Ramadhan

need help here..

i am practicing for OCPJP exam, and i found an explanation that a little bit confusing on Ganesh book..
it is the question..



Which one of the following options correctly describes the behavior of this program?



and the answer is (definitely) --> The program will print : InvalidKeyException exception, but when i saw the explanation, it tells

It is not necessary to provide an Exception thrown by a method when the method is overriding a method defined
with an exception (using the throws clause).



i dont know, but i think it will compiled because the Exception that is thrown by the foo method in DeriDeri class is inherited from unchecked exception.. so it is not necessary to declare throws statement on its method.. and if the exception was checked exception the answer must be different right?
7 years ago
i think you should use method substring and indexOf in java.lang.String Class..

for example :
first, you find the index of "Response" word from your value using indexOf(String value),
then you find the index of first "value" word that occur after indexOf "Response" using(String value, int begin),
etc..

and finally you get the value..

(and actually i think you can use Regex to get cleaner code, but of course need some extra effort to create the pattern )
7 years ago
whoa sorry and thank you btw
7 years ago


hope this can help, btw im using java7
7 years ago
well like Paul said, im not sure "too" what you mean by a temp object.. but i'm trying to answer your question..

Number is an abstract class and we are only able to create reference of an abstract class not an object. But then how a temp Number object is created and returned



"of course" number is an abstract class, thus we're not able to create a "Number" object, but then how a temp Number object is "created" and "returned"?
well actually there's no "Number" object created on your code..



so the object always "Double" which is subclass of the Number class (so it was meet the requirement of the Generic type that you declare -> <Double extends Number>) ..
then what about the getter?



the method never create any "Number" object, but the method was "declared" to return any of "Number" object -> then.. the return statement was a "Double" object (and i'm not sure the doubleValue() was necessary).. then why compiler let the Double object was returned? but AHA we should remember that Double "IS-A" Number right? since the Double is a subclass of Number..

hope this help.. cheers
7 years ago
well im gonna try to help

command "java Yippee" -> "java" is command to execute the java program, then "Yippee" is name of the executed class.. since there's no more command after that, the program didnt send any argument to the main method
command "java Yippee 1 2 3 4" -> just like the prior command, but the program did send 4 arguments (args[0] = 1, args[1] = 2, args[2] = 3, args[3] = 4) and the loop print args[1] to args[3] since the size of the arguments is 4

so the answer should be B i think

*pardon for my bad english