Fiveable
Fiveable

Double

Definition

In Java, Double is both a wrapper class for primitive type double and also represents real numbers with decimal points. It provides useful methods for performing mathematical operations on these numbers.

Related terms

intValue(): This method converts a Double value into an int value.

MAX_VALUE: This constant represents the maximum finite value that can be represented by Double.

isNaN(): This method checks if a Double value is "Not-a-Number" (NaN).

"Double" appears in:

Study guides (2)

  • AP Computer Science A - 1.3 Expressions and Assignment Statements

  • AP Computer Science A - 2.9 Using the Math Class

Additional resources (1)

  • AP Computer Science A - Unit 1 Overview: Primitive Types

Practice Questions (12)

  • What is the result of 'double b = 10.0 / 4'?

  • What is the correct way to cast an integer to a double?

  • What is the value of _a_ in _double a = 3 + 2;_?

  • What is the value of _z_ in _double z = 7 / 2;_?

  • Consider the following method: public void calculatePower(double base, int exponent) { double result = Math.pow(base, exponent); printPower(base, exponent, result); } public void printPower(double base, int exponent, double result) { System.out.print(base + "^" + exponent + " = " + result); } Assume that the method calculatePower(2, 3) appears in a method in the same class. What is printed as a result of the method call?

  • Consider the following method: public void calculateSquareRoot(double n) { double squareRoot = Math.sqrt(n); printSquareRoot(n, squareRoot); } public void printSquareRoot(double n, double squareRoot) { System.out.print("Square root of " + n + " = " + squareRoot); } Assume that the method calculateSquareRoot(16) appears in a method in the same class. What is printed as a result of the method call?

  • What is the result of the following code? public class Shapes { public double calculateCircleArea(double radius) { return Math.PI * Math.pow(radius, 2); } public double calculateRectangleArea(double length, double width) { return length * width; } public static void main(String[] args) { Shapes shapes = new Shapes(); System.out.println(shapes.calculateCircleArea(5) + shapes.calculateRectangleArea(10, 2)); } }

  • Consider the following class definition. public class Animal { private String species; private int age; private double weight; public Animal(String animalSpecies, int animalAge, double animalWeight) { species = animalSpecies; age = animalAge; weight = animalWeight; } public void eat() { weight += 5; } public double getWeight() { return weight; } } Assume that the following code segment appears in a class other than Animal. java Copy code Animal dog = new Animal("Dog", 3, 15); dog.eat(); System.out.println(dog.getWeight()); What is printed as a result of executing the code segment?

  • What is the result of the following code?<br>Double d = 3.14;<br>System.out.println(d);

  • Which of the following is a correct way to convert a double to a Double object?

  • How many parameters does the method with header "public void doSomething (double a, double b, int c, boolean flag, String text)" have?

  • Which statement correctly initializes an array of type `double` with 5 elements?

collegeable - rocket pep

Are you a college student?

  • Study guides for the entire semester

  • 200k practice questions

  • Glossary of 50k key terms - memorize important vocab


Fiveable
About Us

About Fiveable

Blog

Careers

Code of Conduct

Terms of Use

Privacy Policy

CCPA Privacy Policy

Resources

Cram Mode

AP Score Calculators

Study Guides

Practice Quizzes

Glossary

Cram Events

Merch Shop

Crisis Text Line

Help Center

Stay Connected


© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.

About Us

About Fiveable

Blog

Careers

Code of Conduct

Terms of Use

Privacy Policy

CCPA Privacy Policy

Resources

Cram Mode

AP Score Calculators

Study Guides

Practice Quizzes

Glossary

Cram Events

Merch Shop

Crisis Text Line

Help Center

© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.