How 4 and 6 are correct. If we want to aceess a method or a variable of a super class dont we need its object?Even in option 6 super class method is called directly.Is it because it is inherited..??
If u want object of a superclass to access its members in a sub class then what is the point of inheritance??!!
Inheritance is the one which gives you the flexibiity of accessing the super class members in a sub class though it is not actually defined in a sub class.So the options 4 & 6 are correct.
How answer 1 is correct.we are assigning a final variable a method argument value or is it declaring i again as int i in method makes it a local variable and it shadows the instance variable i??
What u said latter is correct.They've declared local variable i which shadows instance variable i.
Can we pass int primitive in a method containing argument of float type??If yes , Is int not casted to float here..How come output is 10I thought it should be 10.0
Trace the program.Before printing to the console they've type casted float to int.So the output should be 10.
A try statement can be use without matching finally or catch clause. Answer: this stament is wrong.Is this statement not correct because its "or". A try block can be used with either only catch or only finally as per my understanding..
No try should be followed by either catch or finally block or even both.Without either of these blocks code will not get compiled.It is also not mandatory that either only catch or finally should follow it..even both blocks can appear after try block.
This is the syntax for try-catch-finally block.If order is changed it will not work.
Fixed. If code or text between tags extends too far to the right, then a scroll bar appears at the bottom of the browser. All the posts had shifted over to the "far side". I have corrected the bad code section, so now you can see your posts once more.
Originally posted by vneeth babu: Given the following code, which of the options if inserted on the line after the comment //here will allow the code to compile without error? I feel even option 1 should be correct, was there any particular explanation why option 1 is not one of the correct choice.
Hmm.. here super() is used and not super.functionName();