File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A few questions, any takers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A few questions, any takers" Watch "A few questions, any takers" New topic
Author

A few questions, any takers

Sanjeev Verma
Ranch Hand

Joined: Aug 24, 2000
Posts: 87
Dear guys,
please spare sometime and help me with these questions:
#1. Given a TextArea using a proportional pitch font and constructed like this:
TextArea t = new TextArea("12345", 5, 5);
Which statement is true?
A. The displayed width shows exactly five characters on each line unless otherwise constrained.
B. The displayed height is five lines unless otherwise constrained.
C. The maximum number of characters in a line will be five.
D. The user will be able to edit the character string.
E. The displayed string can use multiple fonts.
Answers given:B, D
IMHO: Heeeeeeeeeeelppppppppppppp!!!
#2. FilterInputStream is the parent class for BufferedInputStream and DataInputStream. Which classes are a valid argument for the constructor of a FilterInputStream?
A. File
B. InputStream
C. OutputStream
D. FileInputStream
E. RandomAccessFile
Answer given: B
IMHO: B, D
#3. What might cause the current thread to stop executing.
A. An InterruptedException is thrown.
B. The thread executes a wait() call.
C. The thread constructs a new Thread.
D. A thread of higher priority becomes ready.
E. The thread executes a waitforID() call on a MediaTracker.
Answer given: B, D, E
IMHO: B, C (the wording of the question says MIGHT, so imagine a scenario where a thread spawns a new thread and assigns it a priority higher than itself !!!), D, E
#4. What is true about threads that stop executing?
A. When a running thread's suspend() method is called, then it is possible for the thread to indefinitely remain suspended.
B. The interpreter stops when the main method stops.
C. A thread can stop executing when another thread is in a runnable state.
Answer given: C
IMHO: A, B (The main method should be last to finish or else the system may hang), C
BTW, I find the wording of many a questions in online mock testsvery ambigous. I suppose this is not the case in the real thing. Can a experienced hand clarify (and pacify!!!)
Thanx in adv.
Sanjeev
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
for Q1 you can look
here and here...


Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
Aru
Ranch Hand

Joined: Jul 20, 2000
Posts: 112
Sanjeev,
Here are my answers .....
1) TextArea(String s, int rows, int columns) is one of the constructor for TextArea.
Which statement is true?
A. The displayed width shows exactly five characters on each line unless otherwise constrained. - False
B. The displayed height is five lines unless otherwise constrained. - True
C. The maximum number of characters in a line will be five. False
D. The user will be able to edit the character string. - True
E. The displayed string can use multiple fonts. - False
2.FilterInputStream is the parent class for BufferedInputStream and DataInputStream.
Which classes are a valid argument for the constructor of a FilterInputStream?
A. File
B. InputStream - True
C. OutputStream
D. FileInputStream - True
E. RandomAccessFile
3. What might cause the current thread to stop executing.
Here the catch is the word "might" So D is true.
A. An InterruptedException is thrown. - False
B. The thread executes a wait() call. - True
C. The thread constructs a new Thread. - False
D. A thread of higher priority becomes ready. - True
E. The thread executes a waitforID() call on a MediaTracker.-True
4. What is true about threads that stop executing?
A. When a running thread's suspend() method is called, then it is possible for the thread to indefinitely remain suspended.
- True... don't call resume()
B. The interpreter stops when the main method stops.
- False. not always
C. A thread "CAN" stop executing when another thread is in a runnable state. - True. (when other thread of high priority becomes ready)
Please correct me if I am wrong
Hope this helps.
Aruna
scott irwin
Ranch Hand

Joined: Aug 07, 2000
Posts: 87
Q1 - The size of a column is an average width and is platform dependent! So...
A - can't know # shown
B - 5 rows specified to true!
C - Could be many more; false
D - default is editable; true
E - Font is set on the component, so can't do that unless you create some custom component and override paint() to do whacky stuff.
Q2: You da man! The constructor takes InputStream and FileInputStream is one. Maybe the author wanted to know the signature of the constructor which is InputStream.
Q3:I hate this "stop" question. Why don't they reference the thread "state". Then I know what they mean; Dead or non-runnable (waiting, sleeping, blocked). Here they mean non-runnable state. Your example leads to answer D (higher priority).
Q4:A question on a deprecated method, I love it! Accourding to the JavaDoc on Thread (1.3) suspend() keeps the Thread in a non-runnable mode until resume() is called. So, unless they are talking about starting the thread in another VM, answer A sounds good to me!
We know B is false because of spawned threads that are not deamons keep the VM running.
C is very open, and true.
I hope the test has better worded questions than these!!
mohit joshi
Ranch Hand

Joined: Sep 23, 2000
Posts: 243
B (The main method should be last to finish or else the system may hang),
Actually even when the main method finishes execution, the interpreter does not stop, because there may be other threads running. The program actually stops when all (non daemon) threads
finish their execution. Threads marked as Daemon (which process in the background listening to say userinput etc.)may be running when the JVM exits, i.e. the JVM doesnt wait for daemon therads to stop (because the daemon threads may be endlessly executing).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A few questions, any takers