Enable contrast version

Tutor profile: Hyosang A.

Hyosang A.
CS Master's At UCLA | CS Alumni At UIUC

Questions

Subject: Python Programming

TutorMe
Question:

What are the differences between lists and tuples?

Hyosang A.
Answer:

Both lists and tuples are collections of Python elements that do not need to have the same data types. However, the most notable difference between the two data structures is that lists contain mutable elements, whereas tuples contain immutable elements. In other words, an individual element in a tuple can be accessed but can't be modified. ``` l = [3, 5, 1, 7, 9] # l is a list l[1] = 6 # This makes l = [3, 6, 1, 7, 9] t = (3, 5, 1, 7, 9) # t is a tuple t[1] = 6 # Will cause an error because the element can't be modified in a tuple ``` Besides allowing element mutations, lists have more flexibility in element manipulations using built-in methods, such as appending and inserting elements into the sequence, whereas tuples are more appropriate only to access the elements. However, tuples consume less memory to store a series of data, and some built-in and third-party library functions require tuples as inputs, so it is essential to know how to use tuples alongside lists for Python development.

Subject: Java Programming

TutorMe
Question:

When do you use `static` syntax in Java?

Hyosang A.
Answer:

If a variable or method within a class's scope uses a `static` syntax, all objects created under the same class share the same value or content of that variable or method. The `static` keyword is used on variables shared among all objects, such as information that summarizes all objects belonging to the class. Therefore, we can directly use class reference to call a `static` variable or method, unlike non-static variables where the specific object reference is needed. For example, we create a `Person` class to make its objects, but we also want to observe the number of `Person` objects updated each time we create one object. We use the `static` keyword in this situation. ``` class Person { private String name; private int age; public static int numberOfPerson; // Default: 0 public Person(String newName, int newAge) { this.name = newName; this.age = newAge; numberOfPerson++; } ... } ``` Notice that `numberOfPerson` is a `static` variable. Let's run a code snippet creating two `Person` objects as follows: ``` Person a = new Person("Charlie", 8); System.out.println(Person.numberOfPerson); Person b = new Person("Barry", 17); System.out.println(Person.numberOfPerson); ``` The above snippet will produce the following output: ``` 1 2 ``` Even though `Person.numberOfPerson` does not have any reference to a specific object, it has changed upon constructing each object as defined in the class constructor. Like the example, the `static` keyword helps organize shared properties among the objects from the same class.

Subject: Computer Science (General)

TutorMe
Question:

What are the differences between "classes" and "objects" in object-oriented programming?

Hyosang A.
Answer:

A class is an abstract blueprint to construct one or more specific objects. Classes consist of an abstract list of properties that all the objects created from it have. Each object's properties, while they ought to be specified according to the class it's built from, can be unique from each other. Assume we are making characters in a video game you are developing using a class "Character." A Character's properties consist of its name, species, movements, and effect on the main character's health when touched. We can create objects by specifying each object's properties defined in the Character class. For example, one Character has the name "George," and his species is "dog." His movement is simply wandering in the area, and the effect when touched is adding 5 to the main character's health. Another character named "Sam," whose species is "monster," only moves straight toward the main character and deals -5 with the main character's health. As needed in future development, we can create more objects from the Character class. In conclusion, a class is a template with a set of properties it needs to be specified when creating objects based on itself. Such ability to make categorized entities helps developers program more organized manner.

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 Lesson" 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.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by GoGuardian
Copyright © 2022. Zorro Holdco, LLC doing business as TutorMe.
All Rights Reserved.
High Contrast Mode
On
Off