Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.Which of the following shows a static method call? -Character.toUpperCase( 'f' ); -str.toUpperCase(); -this.charAt( 5 ); -test.compareTo( str ); 2.If both Person and Directory implement

1.Which of the following shows a static method call?

-Character.toUpperCase( 'f' );

-str.toUpperCase();

-this.charAt( 5 );

-"test".compareTo( str );

2.If both Person and Directory implement the Printable interface, which of the following lines would not compile? Assume both classes have constructors without parameters.

Group of answer choices

-Printable p = new Directory();

-Person p = new Person();

-Printable p = new Person();

-Person p = new Directory();

-Person p = new Printable();

3.What would be printed by the code below?

public class Person{ private String name; public Person( String name ){ this.name = name; } public void fun( String name ){ String n = "more"; System.out.println( name ); } public static void main( String[] args ){ Person p = new Person( "name" ); String name = "other"; p.fun( name ); } } 

Group of answer choices

-other

-more

-name

4.Which of the following can be instantiated (objects of that type can be created.)

Group of answer choices

-classes

-interfaces

-abstract classes

-primitives

5.Defining a method with the same signature as a method in the parent class is called...

Group of answer choices

-overriding

-inheritance

-implementing

-extending

-overloading

6.In the code below, Cat is the __________ of Animal.

public class Cat implements Animal{ ... } 

Group of answer choices

-subclass

-composition

-superclass

-interface

7.What is printed by the class' main method below?

public class Account { int balance; public int getBalance( ) { return balance; } public void setBalance( int b ) { balance = b; } public void withdraw( int amount ) { balance -= amount; } public static void main( String[] args ) { Account a1 = new Account(); a1.setBalance( 100 ); Account a2 = new Account(); a2.setBalance( 20 ); Account a3 = a1; a3.withdraw( 40 ); System.out.println( a1.getBalance() ); } } 

Group of answer choices

-20

-100

-60

-40

-80

8.Select all methods from the class below that are accessors.

public class Person { String name; int age; public void setName( String n ){ name = n; } public String getName( ) { return name; } public int getAge( ) { return age; } public void setAge( int a ) { age = a; } } 

Group of answer choices

-setAge

-setName

-getAge

-Person

-getName

9.Select all methods from the class below that are mutators.

public class Bicycle { public int cadence; public int speed; public void setCadence(int value){ cadence = value; } public int getCadence(){ return cadence; } public void setSpeed(int value){ speed = value; } public int getSpeed(){ return speed; } } 

Group of answer choices

-getSpeed

-setCadence

-setSpeed

-getCadence

10.What is printed by the class' main method below?

public class Container { int volume; public int getVolume(){ return volume; } public void setVolume(int value){ volume = value; } public void remove(int amount){ volume -= amount; } public void add(int amount){ volume += amount; } public static void main(String[] args){ Container c1 = new Container(); c1.setVolume(400); Container c2 = new Container(); c2.setVolume(600); Container c3 = c1; c3.remove(100); System.out.println(c1.getVolume()); } } 

Group of answer choices

-500

-400

-300

-100

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions