moritz mueller

Greenhorn
+ Follow
since Jan 21, 2010
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 moritz mueller

i hope this / those problems doesn't occur.
It is question 29 of 2nd practice exam:


Given that:
Exception is the superclass of IOException, and
IOException is the superclass of FileNotFoundException, and
3. import java.io.*;
4. class Physicist {
5. void think() throws IOException { }
6. }
7. public class Feynman extends Physicist {
8. public static void main(String[] args) {
9. new Feynman().think();
10. }
11. // insert method here
12. }
Which of the following methods, inserted independently at line 11, compiles? (Choose all
that apply.)
A. void think() throws Exception { }
B. void think() throws FileNotFoundException { }
C. public void think() { }
D. protected void think() throws IOException { }
E. private void think() throws IOException { }
F. void think() { int x = 7/0; }


Answer:

B, C, D, and F are correct....



My answer was / would be C and F - because the method call "new Feynman().think();" doesn't declares or handles an exception. So B and D do cause an compile error. What do you think?
the problem is that this question is related to the chapter that teaches you about locales and their use (to get instances of Date- and NumberFormat) and it teaches you that the jvm has a default locale based on your location. if this knowledge is taken into account the question or answer is wrong. there are many other question that explicitly set and use other locales.
And this is the Problem the output is not locale independent. The problem is that this question silently implies that the code runs in a us locale and this is a question from a chapter that checks your knowledge about locale aware code. Other question from other chapters are expressing environment dependent question more precisly: "What are possible outputs", "What are true for locale us" ...
i am in preparation for ocjp and stumbled accross this question (from study Guide 6):
Given:

Which are true? (Choose all that apply.)
A. The output is 987.12345 987.12345
B. The output is 987.12346 987.12345
C. The output is 987.12345 987.123456
D. The output is 987.12346 987.123456
E. The try/catch block is unnecessary
F. The code compiles and runs without exception
G. The invocation of parse() must be placed within a try/catch block

The Problem is that A,B,C,D are locale aware in and will look different in different countries. But the "correct" answers are D,F and G. Does this kind of problem still persist and every must "think2 in US-Locale?
The answer would be correct with: NumberFormat nf = NumberFormat.getInstance(Locale.US);

In Germany the output look like this:
987,12346
987123456

two lines - the second problem with some answers: sometimes line breaks are printed and some times not (there are answers that only differ in those line breaks)

i'am writing a plain java application with a jpa-db connection. i googled and read about "container-managed" and "application-managed" persistence. i guess in my case of a plain java-application there is no "container"? so i have to managa the resource myself? if so how?

my first idea was to use very local em and emf - instantiated and closed within the methods that interact with db (i made one "db-api-class" on top of the entity classes). the advantag is that all that uses the class don't have to worry about the resource, they don't have to call "close" to free the resources (em and emf and probably transaction?) this class uses. The problem is i have one instance of this resources per instance of the db-api-class?!

my next idea was to have "singleton" fields of this resources (static fields instntiated like singleton classes: if(field==null)..new field)? so what should i do?



thanks in advance
ok reply is working wit ie?! so my reply:

in meantime i tried to copy over the dukeBDay.java - no success. before i copy the rest of the files i would wait for some experts to give additional tips - what to copy first. i am the same kind of java ee noob as you :-)

if you don't have the example in glassfishInstallDir/glassfish/docs/firstcup/example, try the update tool. the tutorial say it could be installed with it.
12 years ago
JSF
hi there,

i have exactly the same problem and google says look here :-). i tired the example firstcup app - delivered with glassfish. this one works fine - without any f:view tags.
i also tried to copy the two xhtml files and the faces-config from example over my files - no succes. so i guess the error isn't in these files?
did you solve the problem mitch?

(one addition: i am using firefox)

is there a way to get compatibility to ie? (probably renaming xhtml->html?)

and another question arose: the tutorial often states "betwwen <body> tag..." i am using netbeans 6.8 and this only generates <h:body> tags and <h:head> tags. does this make any difference? - the delivered example files have <h:head> combined with <body>.

did some more tests, i edited the code of greetings:


the browser shows:

blabla "{bundle}" #{bundle.Welcome} blah

and if i view the source code within firefox - it is exactly the code of greetings.xhtml. nothing is replaced :-(. if i run the example app the hole source code is replace - no h: tags anymore.

For some Reason i can't reply but edit my previous post!: if i click reply i get the login screen, then i typed my login and password and click login -> and i am again on the login screen! (i tested the login by logging out and in again - its wrking)
12 years ago
JSF