• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Marcus exam queries

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,






Thanks in Advance..
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


1.super().output(100);
2.new Wfowl().output(i);
3.class test implements Liz{}
4.System.out.println(sDescription);
5.new Wfowl();
6.getDescription();
Answer:2,3,4,5,6.How 4 and 6 are correct.

If we want to aceess a method or a variable of a super class don't we need its object?

Even in option 6 super class method is called directly.
Is it because it is inherited..??

-------------------------------------------

I feel even option 1 should be correct, was there any particular explanation why option 1 is not one of the correct choice.
[ August 19, 2005: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Priya Jothi
Ranch Hand
Posts: 168
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont understand..where is my prev post & Smitha's post have gone??

Something went wrong..
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Smitha Ballikar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Barry,

Thanks for fixing it up immediately!!Sorry I didnt notice that the code shifted to right..since it normally doesnt happen.

Regards,
Smitha
 
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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();
 
Smitha Ballikar
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you all for your responses!!
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Smitha, you are probably better off asking about one question at a time. That makes it far easier for other people to respond and comment.
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

A try statement can be use without matching finally or catch clause.

i still have doubt ..i knew that try can be used with either catch or finally or both .try cant be used single.

what does the first sentence states clearly ???
plz explain with example like this

try {
}catch{} /*legal*/

try{
}finally /*legal*/

try {
}catch{}
finally{} /*legal*/

then what does that statememt convey???

thanks & regards

srikanth
 
reply
    Bookmark Topic Watch Topic
  • New Topic