Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) How many bytes are in a gigabyte? how many bits? b) In what component of a de

ID: 3769138 • Letter: A

Question

a) How many bytes are in a gigabyte? how many bits?

b) In what component of a desktop computer is most of the computation done?

c) About how fast can the component you mentioned in question b) compute?

d) What's the primary job of the Java compiler? (Hint: it's not to find the errors in my syntax.)

e) Write the single line of code which declares an int x so that x is only directly accessible within its own class.

f) What does it mean to override a method?

g) What does it mean to say that a method is abstract?

Explanation / Answer

a). Digital Storage

1Gigabyte = 1e + 9 bytes

1Gigabyte = 1073741824 bytes

1Gigabyte = 8e + 9 bits

1Gigabyte = 8 589 934 592 bits

b). A desktop computer is a personal computer in a form intended for regular use at a single location desk/table due to its size and power requirements, as opposed to a laptop whose rechargeable battery and compact dimensions allow it to be regularly carried and used in different locations. The most common configuration is a computer monitor, keyboard and mouse, and a case that houses the main components of the PC, namely the power supply, motherboard, hard drive,optical drive, and previously the floppy drive. The form factor of the case is typically an upright tower or (horizontal) desktop. All-in-one computers, that integrate the monitor and main PC components in one unit, are often categorized under the desktop computer umbrella, particularly if they require an external power source and separate keyboard/mouse. The desktop category has also encompassed home computers and workstations.

c).

Computer hardware (usually simply called hardware when a computing context is concerned) is the collection of physical elements that constitutes a computer system. Computer hardware is the physical parts or components of a computer, such as the monitor, mouse,keyboard, computer data storage, hard disk drive (HDD), graphic cards, sound cards, memory, motherboard, and so on, all of which are physical objects that are tangible. In contrast, software is instructions that can be stored and run by hardware.

Software is any set of machine-readable instructions that directs a computer's processor to perform specific operations. A combination of hardware and software forms a usable computing system.

d).

e). With normal variables, we could declare on one line, then initialize on the next:

Each field and method has an access level:

When a class extends another class it’s called inheritance. The class that extends is called sub class while the class that is extended is called super class. Any class in java that does not extend any other class implicitly extends Object class.

In other words every class in java directly or indirectly inherits Object class.

By means of inheritance a class gets all the public, protected properties and methods of the super class no matter which package the sub class is present in. If the sub class is present in the same package as that of super class then it gets the package private properties and methods too. Once the sub class inherits the properties and methods of super class, it can treat them as if it defined them.

By using inheritance you can reuse existing code. If you have an already written class (but no source) and it lacks some features then you don’t have to write everything from scratch. Just extend the class and add a new method that satisfies your needs.

Note: A class can inherit only one class. Multiple inheritance is not supported in Java.

f).

Method Overriding

When a sub class defines a method that has same signature and return type (or compatible with return type of super class method) it is called method overriding.

Example:

Here class B extends class A and overrides the method printIt(). So, when we run the above code the method that gets called is printIt() of class B. By overriding printIt() defined in class A, class B can provide a different implementation to it. Still it can access the super class version of the method by using super keyword.

g).

An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.

An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:

If a class includes abstract methods, then the class itself must be declared abstract, as in:

When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract.

Note: Methods in an interface (see the Interfaces section) that are not declared as default or static are implicitly abstract, so the abstract modifier is not used with interface methods. (It can be used, but it is unnecessary.)