• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 14:23
CET 20:23
KST 04:23
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Revival - 2025 Season Finals Preview8RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12
Community News
Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets0$21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7)12Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns7[BSL21] Non-Korean Championship - Starts Jan 103SC2 All-Star Invitational: Jan 17-1822
StarCraft 2
General
When will we find out if there are more tournament SC2 Spotted on the EWC 2026 list? Weekly Cups (Jan 5-11): Clem wins big offline, Trigger upsets Weekly Cups (Dec 29-Jan 4): Protoss rolls, 2v2 returns Spontaneous hotkey change zerg
Tourneys
$25,000 Streamerzone StarCraft Pro Series announced $21,000 Rongyi Cup Season 3 announced (Jan 22-Feb 7) WardiTV Winter Cup WardiTV Mondays SC2 AI Tournament 2026
Strategy
Simple Questions Simple Answers
Custom Maps
Map Editor closed ?
External Content
Mutation # 508 Violent Night Mutation # 507 Well Trained Mutation # 506 Warp Zone Mutation # 505 Rise From Ashes
Brood War
General
[ASL21] Potential Map Candidates Potential ASL qualifier breakthroughs? A cwal.gg Extension - Easily keep track of anyone BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion
Tourneys
[Megathread] Daily Proleagues [BSL21] Grand Finals - Sunday 21:00 CET [BSL21] Non-Korean Championship - Starts Jan 10 SLON Grand Finals – Season 2
Strategy
Game Theory for Starcraft Simple Questions, Simple Answers Current Meta [G] How to get started on ladder as a new Z player
Other Games
General Games
Beyond All Reason Nintendo Switch Thread Awesome Games Done Quick 2026! Mechabellum Stormgate/Frost Giant Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Trading/Investing Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
Anime Discussion Thread
Sports
2024 - 2026 Football Thread
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List TL+ Announced
Blogs
My 2025 Magic: The Gathering…
DARKING
Physical Exercise (HIIT) Bef…
TrAiDoS
Life Update and thoughts.
FuDDx
How do archons sleep?
8882
James Bond movies ranking - pa…
Topin
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1190 users

Java help

Blogs > Live2Win
Post a Reply
Normal
Live2Win *
Profile Blog Joined July 2004
United States6657 Posts
Last Edited: 2008-02-02 05:28:37
February 02 2008 04:29 GMT
#1
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] +
public static void main(String args[]) {
char alpha;
alpha = “g”;
}


***
SAY YES TO STIM KIDS!!! XD
Chill
Profile Blog Joined January 2005
Calgary25991 Posts
February 02 2008 04:35 GMT
#2
I think
X _= Y means X = X _ Y
So in your example: a = a*b
Moderator
Saracen
Profile Blog Joined December 2007
United States5139 Posts
February 02 2008 04:37 GMT
#3
yeah...
x+=5
is
x=x+5

so i guess what chill said
Saracen
Profile Blog Joined December 2007
United States5139 Posts
February 02 2008 04:40 GMT
#4
answers?
+ Show Spoiler +
a=10.0, b=2.0, c=1.0, d=0.0 ?
Daveed
Profile Blog Joined December 2006
United States236 Posts
February 02 2008 04:42 GMT
#5
If this is a Java question, why don't you open up eclipse or whatever you use, and try some of those expressions?
FreeZEternal
Profile Joined January 2003
Korea (South)3396 Posts
February 02 2008 04:45 GMT
#6
a = 10
b = 1
c = 2
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
Last Edited: 2008-02-02 04:53:01
February 02 2008 04:51 GMT
#7
you ask about multiplication but not modulo? strange

SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
Saracen
Profile Blog Joined December 2007
United States5139 Posts
February 02 2008 04:52 GMT
#8
On February 02 2008 13:51 fusionsdf wrote:
you ask about multiplication but not modulo? strange

modulus doesn't really matter in this question
Live2Win *
Profile Blog Joined July 2004
United States6657 Posts
February 02 2008 04:53 GMT
#9
On February 02 2008 13:51 fusionsdf wrote:
you ask about multiplication but not modulo? strange


I understand modulo :p

I actually looked this up and found out. Thanks for helping out guys.
SAY YES TO STIM KIDS!!! XD
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
February 02 2008 04:53 GMT
#10
yeah but I always found +=, -=,/=, *= intuitive.

modulo confused me quite a bit when I first saw it :O
SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
FreeZEternal
Profile Joined January 2003
Korea (South)3396 Posts
February 02 2008 05:03 GMT
#11
The line c = a % 3 + c / b; is useless here. -.-
Saracen
Profile Blog Joined December 2007
United States5139 Posts
February 02 2008 05:19 GMT
#12
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
Live2Win *
Profile Blog Joined July 2004
United States6657 Posts
February 02 2008 05:25 GMT
#13
On February 02 2008 14:19 Saracen wrote:
Show nested quote +
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

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
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
Last Edited: 2008-02-02 05:34:01
February 02 2008 05:33 GMT
#14
On February 02 2008 14:25 Live2Win wrote:
Show nested quote +
On February 02 2008 14:19 Saracen wrote:
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

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
SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
fusionsdf
Profile Blog Joined June 2006
Canada15390 Posts
February 02 2008 05:38 GMT
#15
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
SKT_Best: "I actually chose Protoss because it was so hard for me to defeat Protoss as a Terran. When I first started Brood War, my main race was Terran."
Macavenger
Profile Blog Joined January 2008
United States1132 Posts
February 02 2008 05:49 GMT
#16
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.
BottleAbuser
Profile Blog Joined December 2007
Korea (South)1888 Posts
Last Edited: 2008-02-02 07:32:06
February 02 2008 07:29 GMT
#17
+ Show Spoiler +
double a = 5, b = 2, c = 6, d;

a *= b; // equivalent to a = a * b, or a = 5 * 2, or a = 10

c = a % 3 + c / b; // equivalent to c = (10 mod 3) + (6 / 2), or c = (1) + (3), or c = 4

c = b– –; //equivalent to c = b; b = b - 1, or c = 2, b = 2 - 1, or c = 2; b = 1

End values:
a = 10
b = 1
c = 2
d is uninitialized.

Also, to set char alpha to lowercase g:

this will work:
char alpha = 'g';

this will also work:
char alpha; alpha = 'g';

this also will work:
char alpha; alpha = 71; // 71 is ASCII for 'g'
Compilers are like boyfriends, you miss a period and they go crazy on you.
BottleAbuser
Profile Blog Joined December 2007
Korea (South)1888 Posts
February 02 2008 07:54 GMT
#18
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.
Compilers are like boyfriends, you miss a period and they go crazy on you.
prOxi.swAMi
Profile Blog Joined November 2004
Australia3091 Posts
Last Edited: 2008-02-02 08:24:27
February 02 2008 08:08 GMT
#19
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?
Oh no
Cambium
Profile Blog Joined June 2004
United States16368 Posts
February 02 2008 08:15 GMT
#20
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.
BottleAbuser
Profile Blog Joined December 2007
Korea (South)1888 Posts
February 02 2008 08:20 GMT
#21
I GOT IT!

It's a fucking trick question! The code won't compile, so a, b, c, and d won't have any value at all! AHAHAHAHAHAHAH. OK, the teacher probably won't accept that answer, so go with what I put in my first post.
Compilers are like boyfriends, you miss a period and they go crazy on you.
Live2Win *
Profile Blog Joined July 2004
United States6657 Posts
February 02 2008 08:54 GMT
#22
lol thanks guys.

I already submitted with d=0. I probably should have put "uninitialized" though, that seems like a better answer.

Thanks for your help though.

Yea, it's for my CIS3022 class
SAY YES TO STIM KIDS!!! XD
Normal
Please log in or register to reply.
Live Events Refresh
Next event in 5h 37m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
UpATreeSC 270
White-Ra 176
JuggernautJason143
BRAT_OK 132
SC2Nice 55
MindelVK 33
StarCraft: Brood War
Shuttle 542
firebathero 137
Dewaltoss 126
Mong 118
scan(afreeca) 21
Dota 2
qojqva3653
Counter-Strike
FalleN 1462
fl0m323
Heroes of the Storm
Liquid`Hasu428
Other Games
Grubby4750
Gorgc2888
Liquid`RaSZi2154
B2W.Neo1891
FrodaN926
Beastyqt926
ceh9494
Fuzer 327
ArmadaUGS228
QueenE121
mouzStarbuck117
Mew2King20
OptimusSC27
Organizations
Other Games
gamesdonequick3504
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 19 non-featured ]
StarCraft 2
• StrangeGG 49
• IndyKCrew
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
StarCraft: Brood War
• HerbMon 23
• FirePhoenix12
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV566
• Noizen39
League of Legends
• Nemesis3030
• TFBlade948
• Shiphtur499
Other Games
• imaqtpie1447
Upcoming Events
PiGosaur Cup
5h 37m
WardiTV Invitational
16h 37m
The PondCast
1d 14h
OSC
1d 16h
OSC
2 days
All Star Teams
3 days
INnoVation vs soO
sOs vs Scarlett
uThermal 2v2 Circuit
3 days
All Star Teams
4 days
MMA vs DongRaeGu
Rogue vs Oliveira
Sparkling Tuna Cup
4 days
OSC
4 days
[ Show More ]
Replay Cast
5 days
Wardi Open
5 days
Liquipedia Results

Completed

Proleague 2026-01-12
Big Gabe Cup #3
NA Kuram Kup

Ongoing

C-Race Season 1
IPSL Winter 2025-26
BSL 21 Non-Korean Championship
CSL 2025 WINTER (S19)
OSC Championship Season 13
Underdog Cup #3
BLAST Bounty Winter Qual
eXTREMESLAND 2025
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025

Upcoming

Escore Tournament S1: W4
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
Rongyi Cup S3
Thunderfire SC2 All-star 2025
Nations Cup 2026
BLAST Open Spring 2026
ESL Pro League Season 23
ESL Pro League Season 23
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.