Results 1 to 13 of 13
- 02-20-2014, 01:00 PM #1
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
What is the result of compiling and running the following program?
public class ThreadMain {
public static void main(String[] args) {
TestThread th = new TestThread ("TestThread");
th.start(TestThread.MIN_PRIORITY);
}
public void run(){
System.out.println("ThreadMain - run");
}
}
class TestThread extends Thread{
public TestThread(String name){
super(name);
}
public TestThread(Runnable runnable){
super(runnable);
}
public void start(int val){
System.out.println(getName()+" - start");
super.start();
}
public void run(){
System.out.println(getName()+" - run");
TestThread thread = new TestThread(new TestRunnable());
thread.start();
}
}
class TestRunnable implements Runnable{
public void run() {
System.out.println("TestRunnable - run");
}
}
- 02-20-2014, 01:10 PM #2
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: What is the result of compiling and running the following program?
Upon compilation there are two possible outcomes.
1. you get compile errors because the code is wrong
2. it compiles
Upon running there are three possible outcomes.
1. it runs, but throws an exception because there is a bug
2. it runs, doesn't produce an exception but produces the wrong results
3. it runs and works as designed
So yeah, go do it yourself. Compile it and if that works, run it and see what happens. Fingers crossed!Last edited by gimbal2; 02-20-2014 at 01:12 PM.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 02-20-2014, 01:13 PM #3
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
Re: What is the result of compiling and running the following program?
thank you for your reply .
- 02-20-2014, 01:16 PM #4
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: What is the result of compiling and running the following program?
Really, that was the answer you wanted? I was basically making a joke.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 02-20-2014, 01:18 PM #5
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
Re: What is the result of compiling and running the following program?
well im new in java programming so ...
- 02-20-2014, 01:19 PM #6
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: What is the result of compiling and running the following program?
I get that. What I don't get is why you then have code with threading. That's an incredibly advanced topic. Also "a test" ?
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 02-20-2014, 01:24 PM #7
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
Re: What is the result of compiling and running the following program?
university brother university .
So do u know whats the output of that ?
- 02-20-2014, 01:28 PM #8
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Re: What is the result of compiling and running the following program?
Well, have you TRIED it yet?
- 02-20-2014, 01:36 PM #9
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
- 02-20-2014, 02:04 PM #10
Senior Member
- Join Date
- Jan 2013
- Posts
- 168
- Rep Power
- 9
Re: What is the result of compiling and running the following program?
Congratulations! That is your output. All you had to do was compile and run it.
- 02-20-2014, 02:13 PM #11
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Re: What is the result of compiling and running the following program?
University, and then this thread is created :s I just can't believe it.
"Syntactic sugar causes cancer of the semicolon." -- Alan Perlis
- 02-20-2014, 02:32 PM #12
Member
- Join Date
- Feb 2014
- Posts
- 9
- Rep Power
- 0
Re: What is the result of compiling and running the following program?
its just a thread ......
- 02-20-2014, 02:33 PM #13
Just a guy
- Join Date
- Jun 2013
- Location
- Netherlands
- Posts
- 5,114
- Rep Power
- 13
Similar Threads
-
Problems with running and compiling application
By lugaru in forum New To JavaReplies: 1Last Post: 07-02-2012, 01:12 AM -
hi the program is compiling but not running why
By javastuden in forum New To JavaReplies: 6Last Post: 09-21-2010, 10:14 AM -
Compiling/Running in Command Prompt
By coke_in_a_can in forum New To JavaReplies: 12Last Post: 05-31-2010, 10:05 AM -
my code compiling but not running
By girishkumar in forum New To JavaReplies: 16Last Post: 03-16-2010, 05:45 PM -
Importing / compiling and running with .jar package
By splinter64uk in forum New To JavaReplies: 1Last Post: 12-05-2007, 03:47 AM
Bookmarks