22 solutions available
Question 1Suppose you want to use the class MyClass of the package MyPackage.UtilityLibrary in a program you are writing. What do you need to do to...
Question 2Explain data input technique in a program using the Scanner class.
Question 3What are delimiters? Which is the default delimiter used in the Scanner class?
Question 4What are errors in a program?
Question 5Explain the following terms, giving an example of each.i. Syntax error
Question 7A program has compiled successfully without any errors. Does this mean the program is error free? Explain.
Question 10What is a java package? Give an example.
Question 11Explain the use of import statement with an example.
Question 12Distinguish between the following:i. next() and nextLine()
Question 13Consider the following input: one, two three, four, fiveWhat values will the following code assign to the variables input1 and input2?...
Question 14Write a line of code that:i. Creates a Scanner object named scanner to be used for taking keyboard input.
Question 15Write a code that creates a Scanner object and sets its delimiter to the dollar sign.
Question 16Write a statement to let the user enter an integer or a double value from the keyboard.
Question 17Write a program in Java that takes input using the Scanner class to calculate the Simple Interest and the Compound Interest with the given...
Question 18Write a program to compute the Time Period (T) of a Simple Pendulum as per the following formula:T = 2π√(L/g)Input the value of L (Length...
Question 19Write a program that takes the distance of the commute in kilometres, the car fuel consumption rate in kilometre per gallon, and the price...
Question 20Write a program in Java that accepts the seconds as input and converts them into the corresponding number of hours, minutes and seconds. A...
Question 21Write a program in Java, using the Scanner methods, to read and display the following details:Name - as a String data typeRoll Number - as...
Question 22Write a Java program that reads a line of text separated by any number of whitespaces and outputs the line with correct spacing, that is,...
Question 6Default delimiter used in the Scanner class is ...........CommaWhitespaceColonThere is no default delimiter.
Question 8Which package would you import for the Scanner class?java.util.*java.awt.*java.io.*java.lang.*
Question 9Errors occur in a program when ...........Syntax of the programming language is not followed.The program does not run properly or does not...