


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



What is the basic structure of a Java program? - Answers โ โ import javax.swing.JOptionPane; public class ProgramName { public static void main(String[] args) { // declare variables // input - > convert - > calculate - > decide - > output } } What does JOptionPane.showInputDialog return? - Answers โ โ It returns a String. How do you convert a String input to an integer in Java? - Answers โ โ Use Integer.parseInt(input). What is the range of the byte data type? - Answers โ โ - 128 to 127.
What is the purpose of the double data type? - Answers โ โ To store decimal numbers with approximately 15 digits of precision. What is the precedence order of arithmetic operators in Java? - Answers โ โ ( ) - > * / % - > + - - > < > <= >= - > == != - > && - > || - > assignment. What does the if statement syntax look like in Java? - Answers โ โ if (condition) { ... } What is the purpose of the CPU in a computer? - Answers โ โ To execute instructions and perform arithmetic and logic operations. What is the role of a compiler in Java? - Answers โ โ It checks syntax and translates Java source code into bytecode. How do you calculate the area of a triangle given its coordinates? - Answers โ โ Use the formula: area = Math.sqrt(s * (s - side1) * (s - side2) * (s - side3)), where s is the semi-perimeter. How do you determine if a point is inside a circle at the origin? - Answers โ โ Calculate the distance from the origin and check if it is less than the radius.
What does the Math.sqrt method do? - Answers โ โ It calculates the square root of a given number. What is the purpose of using parentheses in mathematical formulas in Java? - Answers โ โ To ensure that Java follows the intended order of operations. What is the difference between == and .equals() in Java? - Answers โ โ == checks for reference equality, while .equals() checks for value equality. What is the syntax for a nested if statement in Java? - Answers โ โ if (condition1) { if (condition2) { ... } }