• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

JQuest

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are 2 Q from JQuest
What should be at //A to output running
class RunThread implements runnable {
RunTest rt = new RunTest();
Thread t = new Thread(rt);
// A
}
public void run() {
System.out.println("running");
}
void go(){
start(1);}
void start(int i) {
}
a) t.start();
b)rt.start();
c)System.out.println("running");
d) start(1);
a,c are the given answers. Why is c? I feel only a
Here is my 2nd Q
2) class A {
public void method(int i, floatf){
//Some code
}
}
public class B extends A {
// Comment here
}
What should be // here
a) void method (inti,floatf)
b) public void method(inta,floatb)
c) public void method()
d) protected int method(floatb,int a)
Answers given are b,c,d. i feel only b,c
Can anybody explain?
Madhuri.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Dear
In first example insted of RunTest it should be RunThread,
Problem is what is going to print "running",so if you give just simple System.out.println("running"); it is going to print "running", here it is not going to call run method,so only single "running"is the output.
so both the option given are correct.
About 2 question.
option d is also right because it is the case of overloading ,
option b & c are the case of overriding.
love
Lokesh
 
madhuri vl
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you. so changing the order of the parameters is Overloading.Ok
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic