What do you do when you encounter a test question...

AFB

Lifer
Jan 10, 2004
10,718
3
0
where the teacher has said something breifly in the past that was wrong about it.

For example, on a CS (Java) test I had two questions.

Q: Which of the following can you not store a numerical value in?

a) int
b) double
c) char
d) None of the above work
e) All of the above work

Well, the correct answer is (e) b/c you can cast a number to a char and get it back. We've never done this before so I have no basis for comparison.


Q: [t/f] You have to import the package to use classes outside of java.lang

FALSE: new java.util.Random();

No one else put this, I do remember her stating the opposite a few times before.





 

Colt45

Lifer
Apr 18, 2001
19,720
1
0
1 is E, as far as I can see


Don't trust me though, I get errors compiling hello world.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: Colt45
1 is E, as far as I can see


Don't trust me though, I get errors compiling hello world.

Yeah, it is

char c = (char) 5;
c++;
int myNum = (int) c;
System.out.println(myNum);
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
put down the correct the answer and write something to justify it? that's' what i'd do if i'm positive i'm right

unless it's one of those scanned forms of course...
 

Vertimus

Banned
Apr 2, 2004
1,441
0
0
I don't think there's any other way of storing a 8-bit integer other than storing it in a char. That is why I would put E for 1.
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Originally posted by: Vertimus
I don't think there's any other way of storing a 8-bit integer other than storing it in a char. That is why I would put E for 1.

Java has a byte type and two byte chars.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
1 is C. char data types do not store numbers, they store characters. Just because you can convert between data types does not mean that a char can store numbers. Just because I can convert water to steam does not mean I can store steam in a coffee cup.

And java characters are not 8-bit, they're unicode.