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...
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?
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. 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).
Hello I have a question about Java. example So when you put “sum 1 2 3”...
Hello I have a question about Java. example So when you put “sum 1 2 3” in console, you do not seperate those. Need a space between sum 1, 2 in the console. What is Sum? sum 1 2 3 6 (answer) sum 123456 21 sum 7 4 2 13 public static void main (String[] args) { System.out.Println(“What is Sum?”); String a=“”; a = scnr.nextLine(); String[] b = a.split(“”); if(b[0].equals(“sum”) { } I don’t know how to make code for...
java 1) Create a mutator method called setPosition that accepts one integer parameter. Update the position...
java 1) Create a mutator method called setPosition that accepts one integer parameter. Update the position variable by adding the position to the parameter variable. 2)debug the code public class food { public static void main(String[] args) { Fruits apple = new Fruits(20); // Write the statement to call the method that will increase the instance variable position by 6. Fruits.setPosition(6); apple.getPosition(); } }
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 :)
Please make a Java program that has a menu method and includes dialog boxes. The program...
Please make a Java program that has a menu method and includes dialog boxes. The program will call the proper method, but each method will be completed later. Your program will keep track of information for a Hospital. The program will be menu-driven. Your menu is to look something like the following: UPMC Medical Center Add/Modify Patient Information Add/Modify Physician Information Add/Modify Medical Information Hospital Report Section Exit the Medical System Please Make your selection > In this first phase,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT