Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java, it is legal to have multiple variables with the same name at different scope levels. When this happens, what is the order in

In Java, it is legal to have multiple variables with the same name at different scope levels. When this happens, what is the order in which Java chooses which of the variables to use?
Class or object attributes
Answer 1 Question 5
Choose...
Local variables
Answer 2 Question 5
Choose...
Method parameters
Answer 3 Question 5
Choose...
Question 6
Not yet answered
Marked out of 3.00
Flag question
Question text
Assume a class, OOFClass, defines a constructor with no arguments. You are editing OOFClass, and you want to create a new constructor that reuses the existing constructor to do some of the work. How would you call that constructor?
Question 6Answer
a.
super(), called as the first command in the old constructor
b.
this(), called anywhere in the old constructor
c.
super(), called anywhere in the new constructor
d.
this(), called anywhere in the new constructor
e.
this(), called as the first command in the old constructor
f.
super(), called anywhere in the old constructor
g.
this(), called as the first command in the new constructor
h.
super(), called as the first command in the new constructor
Question 7
Not yet answered
Marked out of 3.00
Flag question
Question text
DESCRIPTION
Scanner keyboard = new Scanner(System.in);
int number =0;
number = keyboard.nextInt();
while (number >0)
{
System.out.println("Hi there" );
number = number * number;
}
QUESTION
How many times will the line containing "Hi there" be output to screen when the above piece of code executes if the user inputs
5?
Question 7Select one:
None of the other options
1
0
10
5
Question 8
Not yet answered
Marked out of 3.00
Flag question
Question text
if ( testMark >=8)
{
System.out.print("I usually remember to work through the skills test bank!");
}
else if ( testMark >=5)
{
System.out.print("I usually remember some of last week's lectures!");
}
else if ( testMark >=2)
{
System.out.print("I usually remember to turn up to my lab!");
}
else
{
System.out.print("I usually remember my password!");
}
Which of the following statements is output to screen if the value of the variable testMark is 6?
Question 8Select one:
I usually remember some of last week's lectures!
I usually remember to work through the skills test bank!
I usually remember my password!
I usually remember to turn up to my lab!
Question 9
Not yet answered
Marked out of 1.00
Flag question
Question text
Select the true statement.
Question 9Select one:
a.
'this' refers to the current method.
b.
'this' can be used inside static (class) methods.
c.
'this' can be used inside instance methods.
Question 10
Not yet answered
Marked out of 1.00
Flag question
Question text
Overloaded methods in a class have:
Question 10Answer
a.
Same name and different signature
b.
Same name but different return type
c.
Different name but same signature
d.
Same name and same signature
Question 11
Not yet answered
Marked out of 3.00
Flag question
Question text
Given the following Java code, what would be the result if 3.14 was entered at the prompt? import java.util.*; public class EchoInteger { public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); System.out.println("Enter an integer: "); int input = keyboard.nextInt(); System.out.println("The integer was "+ input +"."); }}
Question 11Select one:
a.
InputMismatchException
b.
Print out "The integer was 3.14."
c.
Print out "The integer was 3."
Question 12
Not yet answered
Marked out of 3.00
Flag question
Question text
What is the output of this program?
public class Thing
{
public int a;
public static void main(String[] args)
{
Thing thing1= new Thing();
thing1.a =8;
Thing thing2= new Thing();
thing2.a =2;
Thing thing3= thing2;
thing3.a = thing1.a - thing2.a;
System.out.print(thing2.a);
}
}
Answer:Question 12
Question 13
Not yet answered
Marked out of 1.00
Flag question
Question text
Assume a is declared as int[] a ={1,2,3,4,5};. What is the value of a[a.length]?
Question 13Answer
a.
5
b.
0
c.
4
d.
6
e.
Nothing; an exception is thrown
Question 14
Not yet answered
Marked out of 1.00
Flag question
Question text
If the base type of an array is an object type, each element of the array holds _____.
Question 14Answer
a.
the actual value of that element
b.
a reference to an object of that type
c.
0
d.
null
Question 15
Not yet answered
Marked out of 1.00
Flag question
Question text
A _________ access modifier means that the attribute/method is accessible to all subclasses of the class.
Question 15Answer
a.
Protected
b.
Package
c.
Public
d.
Private
Question 16
Not yet answered
Marked out of 1.00
Flag question
Question text
Assume we have two variables declared as int[] a ={1,2,3,4,5}; and int[] b ={1,2,3,4,5};. What is the value of a == b?
Question 16Answer
a.
true
b.
false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions