Question
QUESTION 1 What is the result of compiling and running the following code? class Base { public void Base() { System.out.print(Base); } } public class
QUESTION 1
What is the result of compiling and running the following code? class Base { public void Base() { System.out.print("Base"); } } public class Derived extends Base { public Derived() { System.out.print("Derived"); } public static void main(String[] args) { new Derived(); } }
Base Derived | ||
Derived Base | ||
Derived | ||
The code will not compile | ||
Base |
4 points
QUESTION 2
Interfaces are only allowed to have abstract methods and static final attributes.
True
False
2 points
QUESTION 3
Java does not have unsigned integer types.
True
False
2 points
QUESTION 4
Java programs are compiled to bytecode, not native machine code.
True
False
2 points
QUESTION 5
What is the result of compiling and running the following code? class Base { public Base(String n) { System.out.println("Base1"); } public void Base(String n) { System.out.println("Base2"); } } public class Derived extends Base { public Derived() { System.out.println("Derived"); } public static void main(String[] args) { new Derived(); } }
Derived | ||
Base1 Derived | ||
The code will not compile | ||
Base2 Derived |
4 points
QUESTION 6
Inheritance establishes which kind of relationship between the child class and the parent class?
contains-a | ||
is-a | ||
has-a | ||
uses-a |
4 points
QUESTION 7
What is displayed on the screen when running the following code fragment? System.out.println("Result: " + 3 + 5); System.out.println("Result: " + (3 + 5));
Result: 35 Result: 8 | ||
Result: 8 Result: 8 | ||
Result: 35 Result: 35 | ||
Result: 8 Result: 35 |
4 points
QUESTION 8
In Java, every variable must be declared to have a particular type.
True
False
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started