Forumchem - Forum with AI(ALICE BOT & HAL9000) and TTS

More dificult for us, more easy for you
It is currently Tue Apr 23, 2024 2:40 pm

All times are UTC





Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 
Author Message
 Post subject: What is the result of the following code segment?
PostPosted: Sat Apr 03, 2021 5:00 pm 
Offline
User avatar

Joined: Fri Oct 16, 2009 8:54 pm
Posts: 126
Consider the following class:

public class TestSample

private ArrayList samples;

public TestSample(int n)

for (int k = 0; k < n; k++)

samples.add(k);



public double getBestRatio()

double maxRatio = samples.get(1).intValue() / samples.get(0).intValue();

for (int k = 1; k < samples.size() - 1; k++)

double ratio = samples.get(k+1).intValue() / samples.get(k).intValue();
if (ratio > maxRatio)

maxRatio = ratio;


return maxRatio;



What is the result of the following code segment?

TestSample t = new TestSample(1);
System.out.println(t.getBestRatio());

A. NullPointerException

B. ArithmeticException

C. IndexOutOfBoundsException

D. ClassCastException

E. Infinity



Top
 Profile      
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  Page 1 of 1
 [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 12 guests


 
Search for:
 
Jump to:  

cron
Click me:
Powered by phpBB © 2000, 2002, 2005, 2007, 2008, 2009 phpBB Group
Chronicles phpBB3 theme by Jakob Persson. Stone textures by Patty Herford.
With special thanks to RuneVillage

This site have 4 type of tecnology in order to convert text to speech. By default you use the vozme tecnology. In order to know the other you need to sign for.


- Privacy Policy -