Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve this questions with an explaintion, please. why this one is overloading and the next one is not an overloding or overriding ? I need

solve this questions with an explaintion, please.

why this one is overloading and the next one is not an overloding or overriding ? image text in transcribedimage text in transcribedimage text in transcribedI need an easy technique to solve recursion questions, image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed

2. What type of relationship exists between doJob() in classes A and doJob() in class B? a) Method overriding. b) Method overloading. c) Both method overriding and method overloading. d) Neither method overriding nor method overloading. 4. Given the following definition of Bird and Chicken, which of the given statements will not compile? abstract class Bird implements Livestock \{\} class Chicken extends Bird \{\} M251-MOCK-FINAL-Fall-2020-2021 Page 2 of 10 a) Bird bird = new Chicken(); b) Livestock livestock = new Chicken(); c) Bird bird = new Bird(); d) None of these will compile What does the following function print for n=12345 ? void fun(int n ) \{ if (n==0) return; System.out.println (n10); fun (n/10); \} Answer: 5 3 2 1 a) Change the divide method so that it throws an IllegalArgumentException with an appropriate message if b is zero. Answer: public static double divide (double a, double b) \{ if (b=-0) throw new IllegalArgumentException ("cannot divide by 0 ); return a / b; \} ; b) Change this method so that it catches the IllegalArgumentException thrown by divides and prints the "the divisor is zero" if it is thrown. public static void printQuotient(double a, double b) \{ try{ System.out.println (divide (a, b)); 3 catch (IllegalArgumentException e) } 4. Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct? 1.Aa=newA();2.Aa=newB();3.Bb=newA();4.Bb=newB(); a) 1 and 2 M251-MOCK-FINAL-Fall-2019-2020 Page 2 b) 1 and 3 c) 2 and 4 d) 3 and 4 5. The output of square (3) using the method below is public static int square(int N) if(N=1)return1;elsereturnsquare(N1)+2N1; guess("Tuesday")=guess("esday")+T=(guess("day")+e)+T=((guess("y")+d)+e)+T=((""+d)+e)+T PART2:ShortAnswerQ=("d"+=e)+T ="de"+T = "det" Question 1: What does the following method return for s= "Tuesday"? (Show your working steps in details) publicstaticStringguess(Strings){if(s.length()

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

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions

Question

1. How might volunteering help the employer and the employee?

Answered: 1 week ago