Register


Active : 949
Logged in : 290
Time: 01:32 KST

User Streams
39 online (2 live)
Home | Forum | VODs | Liquibet | Fantasy | Blogs | Liquipedia | Articles | Store
Search TeamLiquid.net
Starcraft Progaming News
[OSL] Reach For The Stars
[TSL] Go Go Go!
[PL] Lim-Jin Rok
[TSL] Ladder with Legends
[OSL] The End of the Begi…
Featured Threads
TL User Locations
Recommended VODs of rece…
Small Vod Thread.
Funny Quotes from TL's I…
Team Liquid Manpower
General Forum
Random pics that make yo…
Marijuana in American Cu…
"Fall of the Republic"
TL.net Ten Commandments
South Park Season 13 Thr…
Starcraft 2 Forum
Vote for SC2 in Spike's …
StarCraft II Q&A Batch 55
Zerg spies?
Data Editor: Mod Examples
Excited about Planetary …
Starcraft: Brood War Forum
[Photos] Post EVER Group…
[SPL] Week 6 Lineups
[Interview] SPL Wemade v…
[Fantasy] PL 09-10 R1 Di…
Post your cheese/rush/fu…
Starcraft Tournaments and Leagues
[SPL] STX Soul vs Samsun…
iG showmatch
[SPL] SK Telecom T1 vs W…
[SPL] Airforce ACE vs KT…
[OSL] Group Selection
Starcraft Strategy Forum
Why does destination fav…
[Q]Protoss FE vs 5 pool?
[Q] Gas Timings for 3Hat…
ZvT 3 Hatch Muta - Adapt…
[Guide] Map Analysis - F…
Sports & Games Forum
[R] Good offline games.
UFC 105 (Nov 14) + UFC 1…
League of Legends
[HoN/DotA] Let's Play~!!
modern warfare 2
Blogs
Starcraft Replays
KawaiiRice - MistrZZZ
By.FlaSh - Best[WHITE]
By.FlaSh - Tempest)Is(
Light[aLive] - By.hero
Bisu - HyuK


Website Feedback

Closed Threads

IRC Updated
irc.quakenet.org #teamliquid

IRC Web Client
New to Team Liquid? Register here!

Java help

Forum index > Blogs 1 2 Next All
  Live2Win   Korea (South). February 02 2008 13:29. Posts 6016Profile Blog 
After the following expressions are evaluated, what are the values of a, b, c, and d? Note that the expressions are all in one program and each expression might affect the next.

double a = 5, b = 2, c = 6, d;
------------------------------
a *= b;
------------------------------
c = a % 3 + c / b;
------------------------------
c = b– –;
------------------------------
a = _____
b = _____
c = _____
d = _____

-----------------------------------------------------------
I don't get what a *= means. I thought you needed a value to multiply a with?

And since I don't get the first one I can't get b, and since I can't get b I can't any of them -.-;;



Also,

Declare a variable alpha of type char and assign it an initial value of the lowercase letter g.

I think that means get alpha and set it to "g". But I don't think my code is right (it doesn't work when it's compiled either).

+ Show Spoiler [Please don't laugh] +
Last edit: 2008-02-02 14:28:37


***
SAY YES TO STIM KIDS!!! XD
Old Post

  Chill   Canada. February 02 2008 13:35. Posts 12186Profile Blog 
I think
X _= Y means X = X _ Y
So in your example: a = a*b
She also isn't my hero. The only hero's I have is our Founders, specifically Thomas Jefferson and my parents.
Old Post

  Saracen   United States. February 02 2008 13:37. Posts 2310Profile Blog 
yeah...
x+=5
is
x=x+5

so i guess what chill said
Old Post

  Saracen   United States. February 02 2008 13:40. Posts 2310Profile Blog 
answers?
+ Show Spoiler +
Old Post

  Daveed   United States. February 02 2008 13:42. Posts 226Profile Blog 
If this is a Java question, why don't you open up eclipse or whatever you use, and try some of those expressions?
Old Post

  FreeZEternal   Korea (South). February 02 2008 13:45. Posts 3005Profile 
a = 10
b = 1
c = 2
Old Post

  fusionsdf   Canada. February 02 2008 13:51. Posts 14042Profile Blog 
you ask about multiplication but not modulo? strange

Last edit: 2008-02-02 13:53:01
MyDream fan | http://www.youtube.com/watch?v=7eqM-42YZxo&fmt=18 ᶫᵒᵛᵉᵧₒᵤ.
Old Post

  Saracen   United States. February 02 2008 13:52. Posts 2310Profile Blog 

On February 02 2008 13:51 fusionsdf wrote:
you ask about multiplication but not modulo? strange

modulus doesn't really matter in this question
Old Post

  Live2Win   Korea (South). February 02 2008 13:53. Posts 6016Profile Blog 

On February 02 2008 13:51 fusionsdf wrote:
you ask about multiplication but not modulo? strange



I understand modulo

I actually looked this up and found out. Thanks for helping out guys.
SAY YES TO STIM KIDS!!! XD
Old Post

  fusionsdf   Canada. February 02 2008 13:53. Posts 14042Profile Blog 
yeah but I always found +=, -=,/=, *= intuitive.

modulo confused me quite a bit when I first saw it :O
MyDream fan | http://www.youtube.com/watch?v=7eqM-42YZxo&fmt=18 ᶫᵒᵛᵉᵧₒᵤ.
Old Post

  FreeZEternal   Korea (South). February 02 2008 14:03. Posts 3005Profile 
The line c = a % 3 + c / b; is useless here. -.-
Old Post

  Saracen   United States. February 02 2008 14:19. Posts 2310Profile Blog 

On February 02 2008 14:03 FreeZEternal wrote:
The line c = a % 3 + c / b; is useless here. -.-

exactly
that's why b=2 and c=1
Old Post

  Live2Win   Korea (South). February 02 2008 14:25. Posts 6016Profile Blog 

On February 02 2008 14:19 Saracen wrote:

Show nested quote +


exactly
that's why b=2 and c=1

why? I don't get why it's useless.

a *= b;
a = a * b
a = 5 * 2
so,
a = 10

c = a % 3 + c / b
c = (10 % 3) + (6 / 2)
c = (1) + (3)
so,
c = 4

c = b--;
c = 2--
so,
c = 2
b = 1

Thus, a = 10, b = 1, c = 2

I'm not sure what "d" is. What's the default for that value?
SAY YES TO STIM KIDS!!! XD
Old Post

  fusionsdf   Canada. February 02 2008 14:33. Posts 14042Profile Blog 

On February 02 2008 14:25 Live2Win wrote:

Show nested quote +


why? I don't get why it's useless.

a *= b;
a = a * b
a = 5 * 2
so,
a = 10

c = a % 3 + c / b
c = (10 % 3) + (6 / 2)
c = (1) + (3)
so,
c = 4

c = b--;
c = 2--
so,
c = 2
b = 1

Thus, a = 10, b = 1, c = 2

I'm not sure what "d" is. What's the default for that value?


because you are setting c to some long equation

and then the very next step you set c to one less than b

In other words, you saved a value to c, didnt use it, and saved over it

as for d, it depends on the language. Java protects you, so it should be 0.0
Last edit: 2008-02-02 14:34:01
MyDream fan | http://www.youtube.com/watch?v=7eqM-42YZxo&fmt=18 ᶫᵒᵛᵉᵧₒᵤ.
Old Post

  fusionsdf   Canada. February 02 2008 14:38. Posts 14042Profile Blog 
for:
public static void main(String args[]) {
char alpha;
alpha = “g”;
}

you have to use single quotes for chars (at least you do in C++ and I assume its the same here)

so it should be
public static void main(String args[]) {
char alpha;
alpha = 'g';
}

or you can combine the two steps to

public static void main(String args[]) {
char alpha = 'g';
}

which will initialize it with a value.


as a follow up to d, java protects you, but some languages don't. be careful relying on the value of a variable you didnt give a value to yet :O
MyDream fan | http://www.youtube.com/watch?v=7eqM-42YZxo&fmt=18 ᶫᵒᵛᵉᵧₒᵤ.
Old Post

  Macavenger   United States. February 02 2008 14:49. Posts 911Profile Blog 
For people saying the final variables are c=1 and b=2, look at it more carefully. b-- means evaluate b, then decrement b. At the start of that step b = 2, so c is set to 2, then b is decremented, giving c = 2 and b = 1. Most of you are doing c = b - 1; which is very different from c = b--;. For c to end up 1 using the -- operator, it would need to be c = --b; which would set both b and c to 1.
Fuck KeSPA | Bisu is long overdue for an OSL title. Kim Taek Yong hwaiting!
Old Post

  BottleAbuser   Korea (South). February 02 2008 16:29. Posts 1386Profile Blog 
+ Show Spoiler +
Last edit: 2008-02-02 16:32:06
(Love ∈ Life) → ¬((Best Things in Life are Free) ∧ (You Get What You Pay For) → (LIFE SUCKS))
Old Post

  BottleAbuser   Korea (South). February 02 2008 16:54. Posts 1386Profile Blog 
Um, what? You'll get a compile error if you try to access d, I think. d is uninitialized.

If d wasn't a primitive type, it would be equal to null. Since it is a primitive type, its value is uninitialized and you'd get a compile error.
(Love ∈ Life) → ¬((Best Things in Life are Free) ∧ (You Get What You Pay For) → (LIFE SUCKS))
Old Post

  prOxi.swAMi   Australia. February 02 2008 17:08. Posts 1941Profile Blog 
oh damn im way too late huh? T_T
anyway bottleabuser is right.
compiler would kick your face for trying to make use of d when there's no gaurantee that it won't be null. However, assuming d was initialized as 0, you'd get a = 10 b = 1 c = 2 d = 0
and the char one .. so ez.
char alpha = 'g';

is this for school?
Last edit: 2008-02-02 17:24:27
http://www.translationparty.com/#4888846
Old Post

  Cambium   Canada. February 02 2008 17:15. Posts 9999Profile Blog 
it's post decrement,

so c is 1 more than b.

and BottleAbuser is right. You can't compile your code unless you have d initialized.
When you want something, all the universe conspires in helping you to achieve it.
Old Post

 1 2 Next All
Calendar
Mo Tu We Th Fr Sa Su
      1
2345678
9101112131415
16171819202122
23242526272829
30      

Live user streams:
KawaiiRice
[ Show 1 non-featured ]

Upcoming events:  [ More ]
@13:00  [PL] STX vs KHAN
@13:00  [PL] hite vs MBC
Nov 23  [KDL] Week 1 Day 1
Team Liquid Progaming Database

League Standings:
» Shinhan 09-10 Proleague
» EVER 2009 OSL
PokerStrategy.com TSL Forum
TSL Player Eligibility a…
TSL Ladder Standings
Official Raffle Entries
TSL Ladder predictions
TSL Cheerfuls
Final Edits: Progaming Editorials
On The Shoulders of Giant…
Here To Stay
A Finale in Five
Masters of the Universe
Map of the Swarm
Power Rank: Progamer Rankings
1. Flash 6. Fantasy
2. Jaedong 7. Effort
3. Inter.Calm 8. Shine[Kal]
4. Stork[gm] 9. HyuK
5. Bisu 10. Kal
   Comments (304)
Poll
TSL Ladder #1?

Comments (133)      Older Polls


International Cyber Cup

Liquid Poker
Sitemap Contact Poker Forum

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2002-2009 Teamliquid.net. All Rights Reserved