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

PLEASE ANSWER FAST ONLY 10 QUESTIONS Which of the following is not a type of pro

ID: 3582448 • Letter: P

Question

PLEASE ANSWER FAST ONLY 10 QUESTIONS

Which of the following is not a type of programming error?
Select one:
a. Logical Error
b. Syntax Error
c. Run-time Error
d. Calculation Error

When you implement a method that is also defined in a superclass, you __________ the original method.
Select one:
a. copy
b. call
c. overload
d. override

The fields in an interface are implicitly specified as,
Select one:
a. private
b. both static and final
c. static only
d. protected

Each class in java has at least one constructor even if you don't create one.
Select one:
a. false
b. true

Which of the following allows you to re-use previosuly written code?
Select one:
a. Encapsulation
b. Inheritance
c. Polymorphism
d. Abstraction

Analyze the following code.
public class Test {
private int t;
public static void main(String[] args) {
int x;
System.out.println(t);
}
}
Select one:
a. t is non-static and it cannot be referenced in a static context in the main method.
b. The program compiles and runs fine.
c. The variable t is not initialized and therefore causes errors.
d. The variable x is not initialized and therefore causes errors.

What tool can be used to represent a class visually with its attributes and methods?
Select one:
a. Recursion
b. UML Class Diagram
c. Constructor
d. ER Diagram

An attribute that is shared by all objects of the class is coded using ________.
Select one:
a. a static variable
b. an instance variable
c. a static method
d. an instance method

A subclass can be abstract even if its ________ is concrete.
Select one:
a. abstraction
b. public method
c. Superclass
d. Constructor

What modifier should you use on a variable so that it can only be referenced inside its defining class.
Select one:
a. public
b. protected
c. private
d. Use the default modifier

Explanation / Answer

Ans. Calculation error

Note: Logical error happens when your code runs but does not give you the desired output, meaning that the logic of your code is not right. Syntax errors occur if you don’t follow the expected syntax rules of the programing language. These are detected at compile time. Run-time errors are the errors which are not detected during compilation of the code but are detected during execution of the code. These may include errors like memory leakage. Etc.

2.     When you implement a method that is also defined in a superclass, you __________ the original method.
Select one:
a. copy
b. call
c. overload
d. override

Ans. Override


Note: When we define a method (in subclass) which is already present in the superclass. Then the function in the sub class will be called when we call it with the object of the sub class. The method in the super class will not be called. This is called method overriding.


Ans. b (both static and final)

Reason: Any implementations can change value of fields if they are not defined as final. Then they would become a part of the implementation. An interface is a pure specification without any implementation. If they are static, then they belong to the interface, and not the object, nor the run-time type of the object.

Ans. True

Reason: Java creates a constructor by default called the default constructor. It is not visible. But it will look like this (see below) if we choose to write it.

                                public Animal() { } //this will be for Animal class

5.     Which of the following allows you to re-use previously written code?
Select one:
a. Encapsulation
b. Inheritance
c. Polymorphism
d. Abstraction


Ans. b. (Inheritance)


Reason: Using Inheritance concept we can reuse the code written in a class. We can inherit that class, i.e. make it superclass and use its methods and attributes without re-writing the code again.

6.     Analyze the following code.
public class Test {
private int t;
public static void main(String[] args) {
int x;
System.out.println(t);
}
}
Select one:
a. t is non-static and it cannot be referenced in a static context in the main method.
b. The program compiles and runs fine.
c. The variable t is not initialized and therefore causes errors.
d. The variable x is not initialized and therefore causes errors.

Ans. a. (t is non-static and it cannot be referenced in a static context in the main method.)

Reason: t is an instance variable. If we want to use it we have to first create an object of class Test before. Then from that object we can access t.

Ans. UML Class Diagram

8.     An attribute that is shared by all objects of the class is coded using ________.
Select one:
a. a static variable
b. an instance variable
c. a static method
d. an instance method

Ans. a. (a static variable)

Reason: If a variable is declared static then it will be shared by all objects. Static variables are used for declaring constants. Even if multiple objects are made they all will have to share that static variable. Instance variable on the other hand will be created separately for each object.

9.     A subclass can be abstract even if its ________ is concrete.
Select one:
a. abstraction
b. public method
c. Superclass
d. Constructor


Ans. c. (Superclass)

10. What modifier should you use on a variable so that it can only be referenced inside its defining class.
Select one:
a. public
b. protected
c. private
d. Use the default modifier

Ans. c. (private)

Note: Methods, variables, and constructors that are declared private can only be accessed within the declared class itself.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote