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

Uni JAVA Exam Monday HELP!!

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey guys, im pretty new to this forum I have only posted once, I tend to spectate more than participate. I'm a first year Computing and Multimedia student at an Australian University and on this monday I will be sitting my first java exam which is worth 60% of my grade so I want to do really well. I have studied very hard and now there are only a couple of concepts that I don't understand and I was hopeing some of you guys could help me out.
The first concept is the selection sort algorithm.
I will try and explain my understanding of it.
Selection sort scans te entire list (int array) and determines the smallest value, this value is then swapped with the value in the first value. Now it scans the list again except for the first value and swaps the next smallest value with the one in the second position. The process continues untill the list is in order.
okay here is an example:
Selection sort example / tutorial
LOL hahaha I understand it now =D don't worry about that one.
Ok now the only concept in my exam I don't understand properlly is Two - Diamentional Arrays
coult someone plz go through them with me or give me a link to some good teachings?
 
Shannon Pink
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok here is an example out of my study guide:
int [ ] [ ] a = { {0, 2, 4, 5, 8},
{10, 1, 3, 6, 9},
{1, 4, 6, 4, 3} };
/*I am really lost when it comes to this, I mean which lot of numbers are stored in the first dimention and which are stored in the second? */
final int ROWS = a.length;
final int COLUMNS = a[0].length;
/*what values are ROWS and COLUMNS assigned? */
int x;
for (int i = 0; i < ROWS; i++)
{
x = a [i] [0];
//again I don't get this

for (int j = 0; j < COLUMNS ; j++)
{
if (a [i] [j] > x)
x = a [i] [j];
}
System.out.println( i + "\t" + x);
}
Could someone please explain all this to me bcause I don't undestant it at all.
What would the output of this code be?
and what would be the value of ROWS and COLUMNS be?

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dingo,
The best way to learn java is to write java, you have plenty of code examples so why not actually try running them and seeing what the results are?
I think this would help you far more than if we just told you
Good luck with the exam
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"DINGO",
Howdy from Perth, but unfortunately your display name is invalid, and accounts with invalid display names get deleted.
Have a look at the naming rules then edit your profile to fix your display name.
Ta,
Dave
[ Oops, typo ]
[ June 27, 2003: Message edited by: David O'Meara ]
 
Shannon Pink
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amy! I see your point and I agree when it comes to some concepts but I do not understand what is going on in this case at all so I would really appeciate if someone could explain to me what is happening in each line. Thanks for your luck though
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shannon Pink
Please FOLLOW what Dave said
Many ranchers can answer you question,after you take action.
 
Shannon Pink
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what dude?! I did take action Shannon Pink is my real name! I originally had it dingo... thanks for the help people.... pfffft!
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shanon,
The idea of 2D Array is similar to how the normal human eye processes the text or data we see in the forms of lines. The idea is.. see when your reading this message of mine the human brain processes the text from the left to the right side and line by line... similarly we need to simulate the process to the language processor what ever language it might be.. Thus when u declare a 2D array the first dimension points at the row no(horizontal cordinate) of the data say and the second dimension points to the column no(vertical cordinate) and this is how the data found at the intersection of both these dimensions is found. Hope I made myself clear. Any further assistance would be my previlege.
All the best,
Gaya3
------------------------------------------------
Beginning is half done
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shannon
Hope your exam went well !
Joe
 
Shannon Pink
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the help Gayathri, I understand that concept now
I think I did really well in the exam there was only one question that I didn't really know how to answer.
cyas later
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Let me try to explain the concept of two dimensional arrays .
when u say int[][] a;
the reference variable 'a' is refering to an
int[][] array object;
Inorder to define the variable 'a' u have to say
a= new int[3][];
The point is JVM needs to know only the size of the object assigned to the variable a.
this will inturn create 3 int[] array object.
each holding there reference variable in a0],
a[1],a[2]. so from here onwards visualize it as reference variable for single dimensional arrrays.
the following code r perfectly OK.
a[0]= new int [5];
a[1]= new int [100];
as u know a[2] will be having a default null value.
so don't think that a two dimensional array will be 2*2 matrix..
hope this will help you
Thomas
 
Hug your destiny! And hug this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic