1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Firlakuza [10]
3 years ago
5

Given the following class code: public class RecurseSample { public static void main(String[] args) { System.out.println(recurse

(3)); } public static int recurse(int n) { int total = 0; if (n == 0) { return 0; } else { total = 3 + recurse(n - 1); } return total; } } What values will be printed when this code is executed?
Computers and Technology
1 answer:
Kipish [7]3 years ago
4 0

Answer:

The output of the given code is "9".

Explanation:

In this question, a class "RecurseSample" inside the class a "recurse" method is declared that holds that holds an integer variable as the parameter, and inside the method a total variable is declared and uses a conditional statement to check the n variable value that is equal to 0 if it is true it will return 0. In the else block it call the method and add value in the total variable, and returns its value. In the main method, the print method is used that prints the above method values.

You might be interested in
Create a project named ClassicBookSelector that contains a Form with a ListBox that lists at least five classic books that you t
STALIN [3.7K]

Answer:

See explaination

Explanation:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

namespace BookListBox

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

string[] Book={"In Search of Lost Time","Ulysses","Don Quixote","The Great Gatsby","One Hundred Years of Solitude"};//declare variable book name

string[] Book_displayMessage = { "In Search of Lost Time by Marcel Proust", " Ulysses by James Joyce", "Don Quixote by Miguel de Cervantes", " The Great Gatsby by F. Scott Fitzgerald", "One Hundred Years of Solitude by Gabriel Garcia Marquez" };//declare variable Short dispay

string[] Book_BrienfSynpsis = { "Swann's Way, the first part of A la recherche de temps perdu, Marcel Proust's seven-part cycle, was published in 1913. In it, Proust introduces the themes that run through the entire work. ", "Ulysses chronicles the passage of Leopold Bloom through Dublin during an ordinary day, June 16, 1904.", "Alonso Quixano, a retired country gentleman in his fifties, lives in an unnamed section of La Mancha with his niece and a housekeeper.", "The novel chronicles an era that Fitzgerald himself dubbed the Jazz Age. ", "One of the 20th century's enduring works, One Hundred Years of Solitude is a widely beloved and acclaimed novel known throughout" };//declare variable Brienf synpsis

private void Form1_Load(object sender, EventArgs e)

{

lblBriefSynopsis.Text = "";//blank display textbox

lbldisplaymessage.Text="";//blank display textbox

for(int i=0;i<5;i++)

lbbook.Items.Add(Book[i]);//add book to listbox

}

private void lbbook_MouseHover(object sender, EventArgs e)

{

Point point = lbbook.PointToClient(Cursor.Position);

int index = lbbook.IndexFromPoint(point);

if (index < 0) return;

//Do any action with the item

lbldisplaymessage.Text = "Here is the Short things about it"+Environment.NewLine+Book_displayMessage[index];

}

private void lbbook_MouseLeave(object sender, EventArgs e)//mouse leave event here

{

lbldisplaymessage.Text = "";//here display message will blank textbox

}

private void lbbook_SelectedIndexChanged(object sender, EventArgs e)

{

}

private void lbbook_MouseClick(object sender, MouseEventArgs e)

{

lblBriefSynopsis.Text = Book_BrienfSynpsis[lbbook.SelectedIndex];//display click brienf Synposis

if (lbbook.SelectedIndex % 5 == 0)

this.BackColor=Color.Blue;

else if (lbbook.SelectedIndex % 5 == 1)

this.BackColor = Color.Red;

else if (lbbook.SelectedIndex % 5 == 2)

this.BackColor = Color.Purple;

else if (lbbook.SelectedIndex % 5 == 3)

this.BackColor = Color.Pink;

else if (lbbook.SelectedIndex % 5 == 4)

this.BackColor = Color.Orange;

}

}

}

4 0
3 years ago
What was Leonardo da Vinci an expert in
Ipatiy [6.2K]

Leonardo da Vinci was a very famous painter. I would assume that he is an expert in painting.

Hope this helped

5 0
4 years ago
If you ship bakudeku. I swear. <br> *RANTS*
Bad White [126]

cries in bakudeku shipper

3 0
3 years ago
Select the correct answer.
riadik2000 [5.3K]

Answer: B- Clip art

Explanation:

5 0
3 years ago
1. Why isn't solar energy usually the only power source for a region?
ale4655 [162]
1. Every region doesnt get the same amount of sunlight as the rest due to whether or location an example would be that a region with alot of rain could have clouds that wouldnt let the solar panels to absorb as much sunlight as a more dry and sunny place 
2 wind farms can be used to store energy for a power outage and a way to lower the cost of electricity to a farmer 
3 using hydro energy requires people to build a dam that pours the water over a mill that rotates and stores energy from it 
4 a type of waste created by nuclear power plants would be daily uses that have radiation such as plastic containers ,gloves , disposable overalls, boots or just plain radioactive waste.
5 would be the total mass of organisms in a given area or volume 
6 is a process to further limit carbon dioxide emissions from burning coal
7 is basically the means to tap into energy savings that over time become an asset 
8 turning down the water heater thermostat and turning off lights when not in use can save energy 
9 smart grids use timing grid to determine how long you use electricity for and for how much you used
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which option will Joan use to get a glimpse of how her presentation will look when she presents it to her audience? Joan will us
    12·1 answer
  • Which of the following is true of an enterprise search software? Select one:
    5·1 answer
  • A dendrochronologist interprets:
    10·2 answers
  • More Loops: All versions of foods.py in this section have avoided using for loops when printing to save space. Choose a version
    13·1 answer
  • Which equation gives you the amount of work performed?
    13·1 answer
  • A technician is configuring a new SOHO multifunction wireless router at a customer’s location to provide network access to sever
    12·1 answer
  • Jimmy wrote the procedure scoreToGrade which accepts as a parameter score - a quiz score in the range 0-100. The procedure is su
    8·1 answer
  • SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
    9·1 answer
  • Do You assign the Needs Met rating before assigning the page quality (PQ) rating?
    11·1 answer
  • Which of these is a way of making applications less vulnerable to hacking?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!