Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Kevin B.
Experienced Programming and database tutor
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

Name one advantage of using an ArrayList collection instead of an array to hold a set of integer values.

Kevin B.
Answer:

There are actually a couple of advantages to using an ArrayList: • An array is fixed size. If you don’t know how much data you will need to store, an ArrayList will resize itself to contain additional data when it runs out of space. With an array, you need to declare it to be larger and then recompile your code. • A collection like ArrayList has methods that make your programming easier. For example, inserting data into the middle of an array is an involved process. You need to move array elements to make an open space to place the new value. ArrayList has an add method that can be used to place a value anywhere in the collection without requiring any additional coding.

C++ Programming
TutorMe
Question:

DirectX and other similar tools used with game will often use large structs to hold data about an object in a game. These structs are passed to methods using points. What are two advantages of this approach to passing data?

Kevin B.
Answer:

The first advantage of using pointers is speed. The location of the struct is passed over rather than taking the time to make a copy of the struct. Passing a location is much faster. The second advantage of pointer use is that changes made in the method to the struct can be seen in the calling routine. If we made a copy of the struct data and passed it to the method, changes made to the struct in the method would only affect the copy, not the original struct. So the calling routine would not see those changes.

C Sharp Programming
TutorMe
Question:

Given a GUI with a Button (button1) labeled “Start” and a Timer that fires events every 50 milliseconds, what does this code do when the Start button is pressed? public partial class Form1 : Form { private Random rgen = new Random(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { int num = rgen.Next(4); switch (num) { case 0: this.Location = new Point(this.Location.X, this.Location.Y + 2); break; case 1: this.Location = new Point(this.Location.X, this.Location.Y - 2); break; case 2: this.Location = new Point(this.Location.X + 2, this.Location.Y); break; case 3: this.Location = new Point(this.Location.X - 2, this.Location.Y); break; } } }

Kevin B.
Answer:

When you press the Start button (named button1 in the code), the event handler button1_Click is called. This code starts the Timer, which then creates Tick events every 50 milliseconds. Every time a Tick event occurs, the timer1_Tick event handler is called. This method will generate a random number between 0 and 3. The random number determines the direction the GUI will move on the screen. This is done by changing the current location of the GUI by 2 pixels in one direction.

Send a message explaining your
needs and Kevin will reply soon.
Contact Kevin
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.