Marcus Deviln

Ranch Hand
+ Follow
since Jan 29, 2009
Merit badge: grant badges
Biography
currently persuing a career in IT. Should have done it a few weeks sooner...
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Marcus Deviln

Hello again folks. Sorry about the previous mistake and I promise to be more careful with my coding. On that note let's try that question again shall we?




and so once again the output is hi hi followed by an exception. The book says the m2 object's m1 instance variable is never initialized so when m5 tries to use it a NullPointerException is thrown. Does that mean that m2 and m1 are referencing the same object? The third line under the class declaration has an initialization for m1 does it not? I'm also not sure about the dot operator. For example when it connects two references what does that mean exactly? Thanks
12 years ago
got this problem in my study guide but don't follow it well:


the output is hi hi followed by an exception due to m5's instance variable? I don't get this dot operator very well
12 years ago
Let me start by saying hello to everyone and I hope that life is good!

Check out this issue...
1) the source:
public class Test3 {
public static void main(String[] args) {
java.util.Date[] dates = new java.util.Date[10];
System.out.println(dates[0]);
System.out.println(dates[0].toString());
}
}

2) the output:
c:\Users\Marcus\My Documents>javac Test3
error: Class names, 'Test3', are only accepted if annotation processing is expli
citly requested
1 error
My question is what caused that output?
13 years ago
Ah Ha!! Chris that worked. TOTALLY ROCKIN!! Thank you so much for your time
13 years ago
I'm trying to put the .class files into a new folder I've made just for that purpose using the -d flag.

c:\Users\Marcus\My Documents>javac -d \bytecode
javac: directory not found: \bytecode
Usage: javac <options> <source files>
use -help for a list of possible options

c:\Users\Marcus\My Documents>javac -d ..\bytecode c:\Users\Marcus\My Documents\J
unk.java
javac: invalid flag: c:\Users\Marcus\My
Usage: javac <options> <source files>
use -help for a list of possible options

I tried a lot of other command possibilities besides these but none are working. What is it I am missing? I'm referring to chapter 10, page 792, Development of Kathy and Berts SCJP study guide
13 years ago
Steven Your'e absolutely right as I'm sure is usually the case. Is this method a valid override? I thought an override had to have a return type that passed the IS-A test.
13 years ago
This should do it. Thank you very much for your help folks.
13 years ago
I made a mistake above. I forgot to comment out method B before getting the above output but here is the output specifically and exclusively concerned with method A:



c:\Users\Marcus\My Documents>javac SuperFoo.java
SuperFoo.java:9: ';' expected
int doStuff() { return 42; }
^
1 error
13 years ago
heres the reference to the question:

"Options A, C, and E are correct. Options B and D are incorrect because an override cannot change the return type unless it's a valid covariant return. Option C is a valid covariant return."

...and here is me trying to compile with method A from above:

c:\Users\Marcus\My Documents>javac SuperFoo.java
SuperFoo.java:10: doStuff(int) in Foo cannot override doStuff(int) in SuperFoo;
attempting to use incompatible return type
found : int
required: SuperFoo
int doStuff(int x) { return 42; }
^
1 error

c:\Users\Marcus\My Documents>

Notice any inconsistencies between what the authors at Sun are saying and what the compiler is saying?
13 years ago

Which three, inserted independently at line 8, will compile? (Choose three.)

// A and B have the same return type don't they? Why does A work and B doesn't?



A
int doStuff() { return 42; }
B
int doStuff(int x) { return 42; }
C
Foo doStuff(int x) { return new Foo(); }
D
Object doStuff(int x) { return new Object(); }
E
SuperFoo doStuff(int x) { return new Foo(); }







courtesy of tmn.sun.com
13 years ago
C:\Windows\System32>cd c:\Program Files\Java\jdk1.6.0_20

c:\Program Files\Java\jdk1.6.0_20>java Child
Variable x is 9



OK great one step taken with several miles to go lovely...
13 years ago
I moved the Java folder into the Program Files directory and when I type: java -version...

c:\Program Files\Java>javac Child.java
javac: file not found: Child.java
Usage: javac <options> <source files>
use -help for a list of possible options

c:\Program Files\Java>javac -version
javac 1.6.0_20

c:\Program Files\Java>java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

c:\Program Files\Java>

...so now the java version is showing up
13 years ago
Does 'jvm.cfg' exist in that exact location? the answer is no, it exists at c:\Java\jre6\lib\i386
13 years ago
C:\Windows\System32>java -version
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'

C:\Windows\System32>javac -version
javac 1.6.0_20

C:\Windows\System32>java -version
Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
13 years ago
The contents of the parentheses on line 9 are not a boolean test as you would usually find but an initialization or other words explicitly setting the test to true. If that's the case then that is surely what I missed.
13 years ago