Worksheet 3
Worksheet 3
SUB:COMPUTER APP
GRADE :10
PRACTICE WORKSHEET-3
CHAPTER : Math Library methods and Input in Java
a3 -y 5
Q4 (i)What is the difference between the Scanner class functions next() and nextLine()?
(II)What are the values stored in variables r1 and r2:
(i) double r1 = Math.abs(Math.min(-2.83,-5.83));
(ii) double r2 = Math.sqrt(Math.floor(16.3));
Q5. Consider the following code and answer the questions that follow:
class academic
{
int x,y;
void access()
{
int a,b;
academic student=new
academic();
System.out.println(“Object
Created”);
}
}
a. What is the object name of the class?
b. Name the instance variables used in the class.
c. Write the name of local variables used in the program.
d. Give the type of function being used and its name.
Q6. Find the errors in the program given below and rewrite the corrected form:
My class
{
int a; int b;
void display()
{
System.out.printIn(a+“ ”+b);
}
static void display2()
{
System.out.println(a+“ ”+b);
}
public static void main(String args[ ])
{
{
My class ob1=new My
class( ); display1().ob1;
display2().ob2;
}
}
}