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?
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.
Get Answers For Free
Most questions answered within 1 hours.