12 years ago
Jump to Forum..
- Boddunan.com Updates
- - Announcements
- - Contests & Rewards
- - Group Discussions
- Discussions
- - General Discussions
- - Improving English Writing Skills
- - Q n A - Find answers to your questions
- - Daily Dose
- - Topics of Interest
- - - Current Affairs & Latest News
- - - Education & Learning
- - - Humor & Jokes
- - - Movies & Entertainment
- Your Vote Counts
- - Feedback
- - Suggestion Box
- Shoutbox
- - Introduce Yourself
- - The Lounge
- - Help
- - Testimonials
Like it on Facebook, Tweet it or share this topic on other bookmarking websites.
12 years ago
Without main, program is nothing.Code won't execute.
In every program,main is necessary.
In every program,main is necessary.
Want to make each day Accountable
12 years ago
Deven saw you after long time. Where were you?
Kha the bhai... kitne dino baad dekha..
Kha the bhai... kitne dino baad dekha..
Want to make each day Accountable
12 years ago
Devan, A program start in java with main function only. static is second step to the program get execution
Slow and Steady Wins the Race.
12 years ago
thank you guys for your answers but i beg to differ with them..i dont know if you have tried it or not but if you make a program in jdk without main but with static block then it still gets compiled and executed without any error
12 years ago
Deven saw you after long time. Where were you?
Kha the bhai... kitne dino baad dekha..
ya bro was kind of busy with my studies and stuff
12 years ago
Just wait Devan
I have taken my Java text just now and it's in my hand.
I want to refer it so that I can answer your question.
Sure, I will do!!!
Wait!!!
I have taken my Java text just now and it's in my hand.
I want to refer it so that I can answer your question.
Sure, I will do!!!
Wait!!!
Meera sandhu
12 years ago
Just wait Devan
I have taken my Java text just now and it's in my hand.
I want to refer it so that I can answer your question.
Sure, I will do!!!
Wait!!!
which book?
12 years ago
Just wait Devan
I have taken my Java text just now and it's in my hand.
I want to refer it so that I can answer your question.
Sure, I will do!!!
Wait!!!
which book?
Complete reference Java 2 :P
I got stuck somewhere..really forget it. Sorry...
I will give you answer..sure
Java is my favourite subject. That's why :P
Meera sandhu
12 years ago
ahem ahem,..im still waiting sandhya
12 years ago
can anyone tell me that when we have static block in java then why do we need main function.
Let me try to find an answer Devan....years have passed since i closed my books :P :P :P
Now also your question is not much clear to me. :blink: Yet, I will try. You can ask me, if still doubts exist.
main() itself is a static block.
Hoping you know it, without which we can't run a OOPS language. Also, all static blocks and variables are executed first before any other objects. Obviously that's why main() runs first while we run a program.
When we declare a variable or method as 'static', it can be accessed before any objects of its class are created and without reference to any object. That's its advantage.
Also all variables declared as static will be global variables too.
Your question is "when we have static block in java then why do we need main function"
So your answer is....main itself is a static block which runs first.
So, obviously a static block is running!!!!
Is your doubt cleared?
If not ask me. I will try to help you. :) :)
Meera sandhu
Page 1 of 2
You do not have permissions to reply to this topic.
Related Topics