Question

1. How do you call a function (method) in Java and how do you call a...

1. How do you call a function (method) in Java and how do you call a Math function, give examples ?

2. What are the advantages of Java Byte Code?

3. How do you read an integer in Java ?

Console--

GUI--

4. What is RAM?

Homework Answers

Answer #1

1. How do you call a function (method) in Java and how do you call a Math function, give examples ?

//Java.Math class has many methods that allows you to perform mathematical tasks on numbers.
import java.math.*; 
public class Main
{
    //method created
static void myMethod() {
  // Math method called
  //Math.min() method returns the smallest of two values passed to it as parameter.
    int min = Math.min(90,20);
    System.out.println("Method Called!!"+ min);
  }

  public static void main(String[] args) {
     //method called 
    myMethod();
  }
}

Note: Java file name is Main.java

Output:

2. What are the advantages of Java Byte Code?

Bytecode in Java is an intermediate machine-independent code. As soon as a java program is compiled, java bytecode is generated.

It helps in achieving the platform-independent goal with the help of bytecode.

It is of low cost however it gives a high return.

It runs on the Java virtual machine only.

It gives flexibility of ‘Write code once, run code anywhere’.

3. How do you read an integer in Java ?

Console-- By using nextInt method of Scanner class we can read integer in Java.

import java.util.Scanner; 
public class Main
{
    //method created
public static void main(String[] args) {

        //This reads the input provided by user using keyboard
        Scanner scan = new Scanner(System.in);
        System.out.print("Enter any number: ");
        // nextInt method reads the number provided using keyboard
        int num = scan.nextInt();
        // Displaying the number 
        System.out.println("The number entered is  "+num);
    }
}

Note: Java file name is Main.java

Output:

GUI-- By using getter setter methods

4. What is RAM?

RAM(Random access memory) is the main memory in a computer, and it is much faster to read from and write to than other kinds of storage, such as a hard disk drive (HDD), solid-state drive (SSD) or optical drive.

RAM is a computer's short-term memory.

RAM is the super-fast and temporary data storage space that a computer needs to access right now or in the next few moments.

Random Access Memory is volatile which means data is present in RAM as long as the computer is on, but it is lost when the computer is turned off.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write Java code that attempts to call a method named bootUp() which takes a String parameter...
Write Java code that attempts to call a method named bootUp() which takes a String parameter and returns an integer value. The String parameter should be read from a file named "bootConfig.txt" and is the only value in the file. If a BootUpException is thrown, print the Exception object's message. If a DriverException occurs, call the reboot() method and rethrow the original DriverException object. If any other type of Exception is thrown, print a generic error message to the console....
(in java) a. Include a good comment when you write the method described below: Write a...
(in java) a. Include a good comment when you write the method described below: Write a method factorial which receives a positive integer n and calculates n! (n factorial), defined as follows: n!=1*2*…*(n-1)*n. For example, 5! = 1*2*3*4*5 = 120. The method should return this value to the calling program. b. Write a driver program (main method) which will read an integer from the console, and pass it to the method to calculate its factorial. The main method then prints...
Java Code: Console IO Practice Exercise The purpose of this exercise is to practice console input...
Java Code: Console IO Practice Exercise The purpose of this exercise is to practice console input and output with the Java console. Setup: Create a class called ConsolePractice with a main method. Create a static field in your class that stores a scanner object. You will use this scanner for all user input. private static Scanner scanner = new Scanner(System.in); Part A: Create a static method called “divide”. Your method should do the following: Accept two integers as parameters, a...
Write a function (java static method) that computes the maximum of two integer. maxOfTwo(1, 2) →...
Write a function (java static method) that computes the maximum of two integer. maxOfTwo(1, 2) → 2 maxOfTwo(2, 1) → 2 maxOfTwo(1, 1) → 1 **(to start use): public int maxOfTwo(int a, int b) { And then complete the function (java static method)MaxOfThree so that it returns the maximum (highest) of the three int values passed as the parameters. maxOfThree(1, 2, 3) → 3 maxOfThree(0, 2, 1) → 2 maxOfThree(88, 4, 5) → 88 **(to start use): public int maxOfThree(int...
1) Why are reader chips now in many smart phone applications .How do they work and...
1) Why are reader chips now in many smart phone applications .How do they work and are they secure? Why? 2) What is binary code? What does it mean to digitize something? 3) What is a GUI. Give two examples of GUIs 4) What is APPADVICE daily and why is worthwhile to use?
1. Prompt the user for a name 2. Call a function that can accept the name...
1. Prompt the user for a name 2. Call a function that can accept the name that the user entered.3. In the function, reverse the name and return the new value to the function call.4. Output to the console "Hi <username>, do you mind if I call you <reversed user name>"? (replace <username> and <reversed user name> with the proper values).
How do you code in Java a method (lets say its called PosOddAverage) that: - Takes...
How do you code in Java a method (lets say its called PosOddAverage) that: - Takes an array of doubles as input - Prints the avearge of positive odd numbers in the array - Prints 'ERROR' for empty input array An Example: Input: [1.2,1.5,0.0,-2.3,3.5,7.1,-1.3] Output: 4.03333333 Thanks :)
Answer the following questions: 1. What is the average cost method and how do you use...
Answer the following questions: 1. What is the average cost method and how do you use it? 2. What is the gross profit method and how do you use it? 3. What is the Inventory Turnover ratio and how do you calculate it? Provide examples. 4. How do you calculate the Inventory Turnover at cost and at retail? What is the difference? 5. (LIFO) costing method: What is it? When do I use it? 6. What is a perpetual inventory...
Java Create a new Drive class. * Create a Menu class. * The menu class will...
Java Create a new Drive class. * Create a Menu class. * The menu class will use the previous 4 classes you created in GCD, LCM, FACTORIAL, DIGITS The Menu will display a menu that give you the option of selecting: 1) Greatest Common Denominator 2) Lowest Common Multiple 3) Factorial 4) Number of Digits in an Integer Enter 1,2,3 or 4: When the User enter the choice, then the correct function/method is called for the class and asks the...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT