• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

jqplus

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I am confuse little bit with these questions, these are from jqplus mock exam.
Q#1
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?
Q#2
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.

vivek
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Regards
Tushar Kansara
------------------
 
Vivek Shrivastava
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I
am still not clear with question one. please do help me.
vivek
 
Ranch Hand
Posts: 1871
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Regds.
Rahul
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vivek,
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.
Rgds,
Shashank
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks.
 
What a show! What atmosphere! What fun! What a tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic