Hi Smitha,
Plz go thru the xplanations for the answers.
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.
try{
}catch(Exception e){
}finally{
}
This is the syntax for try-catch-finally block.If order is changed it will not work.
Hope it helps!!
Regards,
Priya.