Fill This Form To Receive Instant Help
Homework answers / question archive / 1) Describe what arrays are and why they are an important part of computer programming
1) Describe what arrays are and why they are an important part of computer programming.
2. Describe the importance to understanding data encapsulation.
3. Describe the this keyword in Java and why we use it in Object Oriented Programming.
4. Explain the relationship between superclasses and subclasses.
5. Describe the difference between abstract classes and concrete classes.
1.
A data structure that contains a group of elements is known as an array. These items are usually all of the same data type, such as an integer or a string. In computer programs, arrays are widely used to organize data so that a related group of numbers can be readily sorted or searched.
Arrays are important in programming because they:
2.
Data encapsulation is a notion that deals with combining data and how it's modified in a single location. This is accomplished using an object's state (private fields) and actions (public methods).
It states that the state of an object can only be accessed and modified by behaviors. The values contained within the state of an object can then be tightly managed.
It also ensures that the inner workings of the object are kept hidden. The behaviors are the sole component of the item that is visible to the outside world. The inner workings of those behaviors, as well as how the state is stored, are hidden from view.
Encapsulation is important because:
3.
In a method or constructor, the this keyword refers to the current object.
This keyword is most commonly used to distinguish between class characteristics and arguments with the same name (because a class attribute is shadowed by a method or constructor parameter). If you don't include the keyword in the example above, the result will be "0" rather than "5".
This can be used for a variety of purposes, including:
Step-by-step explanation
4.
A subclass cannot access a superclass's private members, but it can access non-private members.
A subclass can use the keyword super, followed by a set of parentheses containing the superclass constructor parameters, to call a constructor of its superclass. This must be the first statement in the body of the subclass constructor.
A superclass method can be overridden by a subclass to declare a subclass-specific implementation.
A method should override a superclass method using the @Override annotation. When the compiler comes across a method defined with @Override, it compares its signature to the method signatures of the superclass.
In Java, attributes, and methods can be passed down from one class to the next. The "inheritance concept" is divided into two categories: The class that inherits from another class is called a subclass (child). The superclass (parent) from which the class is inherited. Use the extends keyword to inherit from a class.
A superclass/subclass connection is the relationship between a superclass and any of its subclasses.
5.
A concrete class is a subclass of an abstract class that implements all of the abstract methods of the abstract class while abstract methods are unable to have a body.
Like regular classes, abstract classes can have static fields and static methods while it is not possible to declare an abstract class as final. Abstract methods can only be found in abstract classes.
An abstract modifier is used to declare an abstract class. When a concrete class is specified using the abstract keyword, it becomes an abstract class as well.
Instantiation: An abstract class cannot be directly instantiated, which means that an object of such a class cannot be generated using the new keyword. A concrete subclass can instantiate an abstract class, or all of the abstract methods can be defined together with the new statement. A new keyword can be used to directly instantiate a concrete class.
Abstract methods may or may not exist in an abstract class. A concrete class cannot have an abstract method because an abstract method requires an abstract class.