473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

java question

8
what is the correct answer of thes question....

public class par
{

public static void main (String[] args)
{
int i=0;
addtwo(i++)
system.out.println(i);
}
static void addtwo(int i)
{
i+=2;
}
}
Mar 28 '08 #1
19 1174
JosAH
11,448 Expert 8TB
what is the correct answer of thes question....
What do *you* think the answer is? We are not an answering service; please
try to think about those questions yourself.

kind regards,

Jos (mod)

ps. read the forum quidelines (see the 'Help' link near the top of this page)
Mar 28 '08 #2
shirsa
8
What do *you* think the answer is? We are not an answering service; please
try to think about those questions yourself.

kind regards,

Jos (mod)

ps. read the forum quidelines (see the 'Help' link near the top of this page)
then plz change the title of the site
"Java Forum
Java programming help. Post your Java questions in this forum. "
Mar 28 '08 #3
JosAH
11,448 Expert 8TB
then plz change the title of the site
"Java Forum
Java programming help. Post your Java questions in this forum. "
No, *you* program your Java programs and we can help you with it; we don't
just supply answers to arbitrary questions so you can just copy and paste
them and turn them in as if they were your intellectual work.

kind regards,

Jos (mod)
Mar 28 '08 #4
r035198x
13,262 8TB
then plz change the title of the site
"Java Forum
Java programming help. Post your Java questions in this forum. "
There's no need to change the title it's still valid.
You can post your Java questions here but you must post them according to the posting guidelines
Mar 28 '08 #5
shirsa
8
then tell me that whether i'm right or wrong
the ans is 2
Mar 28 '08 #6
r035198x
13,262 8TB
then tell me that whether i'm right or wrong
the ans is 2
Hopefully you are not demanding answers because experts here give their help free of charge. It is only fair that you be polite to them as well.
How did you come up with the answer 2? By the answer do you mean the output?

P.S You can check on a compiler whether you are right or wrong.
Mar 28 '08 #7
shirsa
8
Hopefully you are not demanding answers because experts here give their help free of charge. It is only fair that you be polite to them as well.
How did you come up with the answer 2? By the answer do you mean the output?

P.S You can check on a compiler whether you are right or wrong.

as i++ return the value before increment...so "static void addtwo " this function will give the ans 0+2=2 .....
is it right?

i have not the compiler so i'm asking....ok then goodbye
Mar 28 '08 #8
r035198x
13,262 8TB
as i++ return the value before increment...so "static void addtwo " this function will give the ans 0+2=2 .....
is it right?

i have not the compiler so i'm asking....ok then goodbye
But that i that is incremented by two is not the same as the i that is printed in your main (your println statement needs an uppercase S for system BTW).
Mar 28 '08 #9
shirsa
8
But that i that is incremented by two is not the same as the i that is printed in your main (your println statement needs an uppercase S for system BTW).
ok thanks....i got it...thank you very much....
Mar 28 '08 #10
shirsa
8
now i've another question may i ask u?
Mar 28 '08 #11
r035198x
13,262 8TB
now i've another question may i ask u?
As long as you stick to the posting guidelines you can go ahead and ask.
If it's a different question you'll want to start another thread for it and give it a title that is problem specific. Then you'll need to explain what you have tried as well.
Mar 28 '08 #12
shirsa
8
in java
x[0]++,
is it legal??
Mar 28 '08 #13
pralu
34
the answer to ur question is 1.... its not 2
Mar 28 '08 #14
r035198x
13,262 8TB
in java
x[0]++,
is it legal??
Read my reply above again.
Also download and read the Java tutorial from Sun. There's no point in trying to answer Java questions before about the Java language itself. You'll be able to answer all of those questions yourself after reading the relevant parts of that tutorial.
Mar 28 '08 #15
shirsa
8
thanks...
x[0]++ is it legal?
Mar 28 '08 #16
pralu
34
thanks...
x[0]++ is it legal?

ya its legal .... in doing this ....
Mar 28 '08 #17
r035198x
13,262 8TB
thanks...
x[0]++ is it legal?
This is not getting anywhere. You are ignoring my responses.
I will now close this thread. Realize that persistence in not following the posting guidelines will only result in your account getting banned.
Mar 28 '08 #18
r035198x
13,262 8TB
ya its legal .... in doing this ....
Please do not post wrong information. Realize also that spoonfeeding is against site rules and may result in your account getting banned.
Mar 28 '08 #19
JosAH
11,448 Expert 8TB
the answer to ur question is 1.... its not 2
Please stop posting spoon feeding code and supplying answers without any
reasoning. Do you think that will help the OP to understand the question?
No it doesn't; if you really must supply the party pooper answer at least give
a rationale and explain *why* your answer is supposedly correct. Better help
the OP to find the correct answer her/himself.

Read the forum guidelines; you'll risk a ban if you continue like this. Consider
this reply a warning.

kind regards,

Jos (mod)
Mar 28 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: gmcdanie | last post by:
I am looking for a Java Decompiler... preferably free. Any suggestions. Ease of use isn't a problem as long as it does a fair job.
73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
9
by: babylon | last post by:
i just read this (http://java.sun.com/developer/technicalArticles/releases/j2se15/) am I correcting on these concepts? Java Metadata == C# Attribute (java learn from c#?) Java Generics == C#...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
15
by: himilecyclist | last post by:
My State government organization has written a PHP/MySQL application which has been in production for about 6 months and has been highly successful. We are now embarking on a similar database...
0
by: Aaron J. Margosis | last post by:
I'm not a Java programmer, but I'm trying to solve some application compatibility issues with locked down security settings on Windows. My question: How do different Java-delivery tools invoke...
63
by: s0suk3 | last post by:
I've been programming Python for a couple of years now. Now I'm looking to move on to either C++ or Java, but I'm not sure which. Which one do you think will be a better transition for a Python...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.