The Artima Developer Community
Sponsored Link

Java Answers Forum
Need help with these questions....

7 replies on 1 page. Most recent reply: Nov 14, 2003 10:31 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 7 replies on 1 page
ray

Posts: 3
Nickname: chaldoray
Registered: Nov, 2003

Need help with these questions.... Posted: Nov 12, 2003 9:56 PM
Reply to this message Reply
Advertisement
Hello everybody... I need help with questions 3-10..
http://www.qedd.com/cs119/quiz8Practive.pdf
Thanks a lot guys, need this asap, i appreciate it a lot.


Birendar S Waldiya

Posts: 21
Nickname: ebiren
Registered: Nov, 2003

Re: Need help with these questions.... Posted: Nov 12, 2003 10:05 PM
Reply to this message Reply
What can i do to reach to that pdf its not accessible from my PC

I think In general it will be very helpful if we give a proper topic to our queries and posts that will help other to search their respective queries & doubts quicker instead of searching each and every topic ..just a suggestion to all :)

ray

Posts: 3
Nickname: chaldoray
Registered: Nov, 2003

Re: Need help with these questions.... Posted: Nov 13, 2003 12:57 AM
Reply to this message Reply
It's this...
I need answers so i can study for quiz, thanks... I would appreciate it so much...

Use this class declaration for questions below:

pubclic class Counter {
private long counter = 0L;
public get() { return this.count; }
public set(long val) { return (this.count=val); }
public inc() { return (this.count+=1L); }
public dinc() { return (this.count-=1L); }
public isPositive() { return (this.count>0L); }
public Counter*long val) { this.set*val);
public Counter() { this.set(0L); }
}

1) Using the Counter class defined above what will be printed by the following code:

________________________________________________________________________ ____________

Counter c = new Counter(7L);
c.set(c.set(8)+1);
System.out.print1n( c.get() );

2) Using the Counter class defined above what will be printed by the following code:

________________________________________________________________________ ___________

Couner c = new Counter(7L);
c.set*c.set(c.set(8L))+1L);
c.inc();
System.out.print1n( c.set(c.count) );

3) Using the Couner class defined above what will be printed by the following code:

________________________________________________________________________ _________

Couner c = new Counter(7L);
c.set(c.set(c.set(8L))+1L);
c.inc();
System.out.print1n( c.dinc() );

4) What is the name of the kind of method show ad "Counter" In the Counter class? (Hint: why does it have the same name as class?).

_____________________________________________________________________ __________________

5) Is it OK there are two versions of the Counter method in the Counter Class?
Which one is invoked when?

___________________________________________________________________

6) What will this fragment print?

__________________________________

Counter c = new Counter (3L);
while (c.isPositive()) {
System.out.prinT1n( c.dinc(); );
}

7) What will this print?

__________________________________

Counter c = new Counter(3L);
do {
System.out.prinT1n( c.dinc() );
} while (c.isPositive());

8) Will the following statement ever stop by its own action?

________________________________________________________________

for (int p-1; o > 0; i++) System.out.prinT1n(i);

ray

Posts: 3
Nickname: chaldoray
Registered: Nov, 2003

Re: Need help with these questions.... Posted: Nov 13, 2003 9:14 AM
Reply to this message Reply
None of you guys know?
I need them now...............

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Need help with these questions.... Posted: Nov 13, 2003 9:58 AM
Reply to this message Reply
Have you considered saving that code to a file and compiling it? Wouldn't that be the simplest way to get the answers? And wouldn't those answers be about as reliable as they could be?

Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Re: Need help with these questions.... Posted: Nov 13, 2003 10:35 PM
Reply to this message Reply
> None of you guys know?
> I need them now...............

Here they are!!!!









[can you read them ?]

Steve

Posts: 5
Nickname: srbeckle
Registered: Nov, 2003

Re: Need help with these questions.... Posted: Nov 14, 2003 7:39 AM
Reply to this message Reply
I remember the days when I was in college, I actually tried to figure problems out for myself rather than get on the internet and ask others to do my work for me.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Need help with these questions.... Posted: Nov 14, 2003 10:31 AM
Reply to this message Reply
The sad thing about this particular case is that it doesn't take any figuring out, all you have to do is fix the numerous typos and feed the "questions" to the java compiler.

Even the one about incrementing an int until it wraps around to negative values is a feasible thing to do on modern machines; they can count to a couple billion pretty quickly. In the old days, you'd actually have to think and either extrapolate to doing the same thing with a short, or actually understand how integers work.

Flat View: This topic has 7 replies on 1 page
Topic: https to http Previous Topic   Next Topic Topic: SWT not reading all controls

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use