jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes jqplus 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 "jqplus" Watch "jqplus" New topic


Vivek Shrivastava
Ranch Hand

Joined: Jun 03, 2000
Posts: 277
I am confuse little bit with these questions, these are from jqplus mock exam.
if u cerate a List using the following line of code
java.awt.List list = new List();
which of the given statement are correct?
1. It will not allow multiple selections
2. The list has four visible items.
3. A vertical scroll bar will be added automatically if needed.
4. A list cannot be constructed this way.
5. None of the above.
given answer 1,2,3. i dont have idea about '2'. is it correct?
How can u declare variable 'i' so that it is not visible outside the package 'test'
package test;
class Test
XXX int i;
/* Lots of code*/
1. private
2. public
3. protected
4. no access modifer.
given answer is 1,4. i do agree with '4' but i don't think '1' is correct answer.
please explain it to me.

Tushar Kansara
Ranch Hand

Joined: Aug 14, 2000
Posts: 38
Must be a error in the exam, for the second question variable to be hidden outside the package actually means accessibility of the class itself & then the variable.
Public is out of question & so is private What remains is protected & friendly. As much as I know protected allows access within the package and all the subclasses irrespective of the package they reside in hence the correct answer i suppose is Friendly.
Friends correct me if i am wrong.
The First question I have checked the Java API. The List() constructor by default creates 4 visible lines with multiselection mode disabled, hence the correct answer u have guessed it is 1 & 2. I am not sure about option 3.
Tushar Kansara
Vivek Shrivastava
Ranch Hand

Joined: Jun 03, 2000
Posts: 277
am still not clear with question one. please do help me.
Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1868
The question does not talk of accessability within the package as such the variable can be private. However if the variable is public or protected it would be accessible outside the package. Thus the answers are correct.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
When the java.awt.List is created using the no argument constructor, the default behaviour is to create four visible lines and default selection disabled.
I have no idea, why the number 4 was chosen. But I guess you will just have to remember this point for the exam.
Harry Chawla
Ranch Hand

Joined: Jun 03, 2000
Posts: 97
RHE mentions on page 323, second sentence under List heading:
"If a list contains more items than it can display, it acquires a vertical scroll bar"
What I infer from it is that if required, it acquires vertical scroll bar.
I agree. Here's the link: http://aspose.com/file-tools
subject: jqplus
It's not a secret anymore!