• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

A few questions, any takers

 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for Q1 you can look
here and here...
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic