Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Mock exam q's doubt

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i was going thru one of the mock exams onthe net .there was a q's which was as follows
Q3.Which of the given choices are true?Select any two.
1 class Q3
2 {
3 public static void main(String arg[])
4 {
5 int[] a,c,d[];
6 int b[]=new int[0];
7 }
8 }
options :
1) All the variables a,b,c,d are arrays.
2) Only a,d,b are arrays.
3) We can declare an array with zero element.
4) We cannot declare an array with zero element.
i thought the answers were 2& 3 but when i checked it was as 1 & 3. please let me know whether i am correct or not and why in case i am wrong .
Thanks is advance
Lakshmi
--------------------------------------------------------------------------------
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think c is array, it belongs to the declaration int[], isn't it? but I am not sure.

Originally posted by lakshmi panda:
hi
i was going thru one of the mock exams onthe net .there was a q's which was as follows
Q3.Which of the given choices are true?Select any two.
1 class Q3
2 {
3 public static void main(String arg[])
4 {
5 int[] a,c,d[];
6 int b[]=new int[0];
7 }
8 }
options :
1) All the variables a,b,c,d are arrays.
2) Only a,d,b are arrays.
3) We can declare an array with zero element.
4) We cannot declare an array with zero element.
i thought the answers were 2& 3 but when i checked it was as 1 & 3. please let me know whether i am correct or not and why in case i am wrong .
Thanks is advance
Lakshmi


 
lp
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
incase c is array then why did they specifically declare d aas an array in the declararion .
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when you declare int[] ... in a line with ",", all the variables are array. In this question, d is an array of array. And in deed, you can have a array with 0 element.
hope it helps.
By the way, when did i become a ranch hand?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You were promoted due to all your hard work and helping others. Or maybe it was when you reached 30 posts.
All of the variables are arrays.

int a,b,c; // declares a,b,c as ints
int[] e,f,g // declares e,f,g as arrays of ints
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that was a mock question so they wanted to confuse by writing in one line.
Thanx
Rajani
 
lp
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u all ,now i got my doubt clear.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic