Chapter 6_ Input in Java _ Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java _ KnowledgeBoat
Chapter 6_ Input in Java _ Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java _ KnowledgeBoat
Home / Class 10 - Logix Kips ICSE Computer Applications with BlueJ / Input in Java
CONTENTS
Chapter 6
Search by lesson title
Input in Java Multiple Choice Questions
Chapter 2
Introduction to Java
Chapter 3
Values and Data Types
TMS Climate Change Conference
Chapter 4
Operators in Java
Join Us in Making a Positive Impact on The World, Book Now
Chapter 5 & Get 20% Off
User-Defined Methods
Chapter 6
Input in Java
Chapter 8
Conditional Constructs in Java
Multiple Choice Questions
Chapter 9
Iterative Constructs in Java
Question 1
Chapter 10
Nested for loops
A programmer wrote the following statement:
Chapter 11
netPay = grossPay + providentFund;
Constructors
instead of:
netPay = grossPay - providentFund;
Assuming all the unseen code is correct, what kind of error is it?
1. Syntax error
2. Runtime error
3. Logical error ✓
4. None of these
Question 2
Question 3
Question 4
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 1/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
1. import ✓
2. export
3. include
4. impart
Question 5
1. next()
2. nextInt()
3. nextLong()
4. nextNumber() ✓
Question 6
1. Comma
2. Whitespace ✓
3. Colon
4. There is no default delimiter.
Question 7
Which package would you import to display the date and time?
1. java.util.* ✓
2. java.Date.*
3. java.io.*
4. java.lang.*
Question 8
1. java.util.* ✓
2. java.awt.*
3. java.io.*
4. java.lang.*
Question 9
Question 10
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 2/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
1. a keyboard
2. a file
3. a string
4. All of these ✓
Assignment Questions
Question 1
Answer
import MyPackage.UtilityLibrary.MyClass;
Answer
import MyPackage.UtilityLibrary.*;
Question 2
Answer
Question 3
Answer
Question 4
Answer
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 3/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 5
i. Syntax error
Answer
Syntax Errors are the errors that occur when we violate the rules of
writing the statements of the programming language. These errors
are reported by the compiler and they prevent the program from
executing. For example, the following statement will give an error
as we missed terminating it with a semicolon:
int sum
Answer
Errors that occur during the execution of the program primarily due
to the state of the program which can only be resolved at runtime
are called Run Time errors.
Consider the below example:
import java.util.Scanner;
class RunTimeError
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
int n = in.nextInt();
int result = 100 / n;
System.out.println("Result = " + result);
}
}
This program will work fine for all non-zero values of n entered by
the user. When the user enters zero, a run-time error will occur as
the program is trying to perform an illegal mathematical operation
of division by 0. When we are compiling the program, we cannot
say if division by 0 error will occur or not. It entirely depends on the
state of the program at run-time.
Answer
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 4/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
class RectanglePerimeter
{
public static void main(String args[]) {
int l = 2, b = 4;
double perimeter = 2 * (l * b); //This line has a l
System.out.println("Perimeter = " + perimeter);
}
}
Output
Perimeter = 16
perimeter = 2 * (l + b); .
Question 6
Answer
Syntax error
Question 7
Answer
Question 8
Answer
Question 9
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 5/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
Question 10
Answer
Question 11
Answer
import java.util.*;
Question 12
Answer
next() nextLine()
It reads the input only till the It reads the input till the end
next complete token until the of line so it can read a full
delimiter is encountered. sentence including spaces.
Answer
next() next().charAt(0)
It reads the input only till It reads the complete token and
the next complete token then the first character is
until the delimiter is returned using the charAt(0)
encountered. method.
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 6/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
next() next().charAt(0)
Answer
next() hasNext()
It returns a boolean
It returns a String value.
value.
Answer
hasNext() hasNextLine()
Question 13
What values will the following code assign to the variables input1
and input2?
Answer
input1 ⇒ one,
input2 ⇒ two
Question 14
Answer
ii. Uses the object scanner to read a word from the keyboard and
store it in the String variable named stg.
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 7/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
Question 15
Write a code that creates a Scanner object and sets its delimiter to
the dollar sign.
Answer
Question 16
Answer
Question 17
Write a program in Java that takes input using the Scanner class to
calculate the Simple Interest and the Compound Interest with the
given values:
i. Simple interest
Answer
import java.util.Scanner;
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 8/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
double si = p * r * t / 100.0;
double cAmt = (p * Math.pow(1 + (r / 100), t));
double ci = cAmt - p;
double diff = Math.abs(si - ci);
in.close();
}
}
Output
Question 18
T = 2π√(L/g)
Answer
import java.util.Scanner;
Output
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 9/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Question 19
Answer
import java.util.Scanner;
Output
Question 20
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 10/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Answer
import java.util.Scanner;
Output
Question 21
Answer
import java.util.Scanner;
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 11/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
public class KboatMarks
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter name: ");
String name = in.nextLine();
System.out.print("Enter Roll Number: ");
int rollNo = in.nextInt();
System.out.print("Enter Marks in 1st Subject: ");
float m1 = in.nextFloat();
System.out.print("Enter Marks in 2nd Subject: ");
float m2 = in.nextFloat();
System.out.print("Enter Marks in 3rd Subject: ");
float m3 = in.nextFloat();
System.out.print("Enter Marks in 4th Subject: ");
float m4 = in.nextFloat();
System.out.print("Enter Marks in 5th Subject: ");
float m5 = in.nextFloat();
float t = m1 + m2 + m3 + m4 + m5;
float p = t / 500 * 100;
System.out.println("Percentage Marks = " + p);
in.close();
}
}
Output
Question 22
Answer
import java.util.Scanner;
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 12/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
System.out.print(w + " ");
}
in.close();
}
}
Output
Prev Next
User-Defined Methods Mathematical Library Methods
Sharjah to Dhaka
Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy
Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service
Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications
Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers
Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following
Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions
Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions
Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions
Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions
Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 13/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
Class - 8 Concise Chemistry Selina Solutions Class - 10 NCERT Science Solutions
Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions
Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions
Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions
Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions
Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions
Class - 8 APC Understanding Computers Solutions Class - 12 CBSE Preeti Arora Python Solutions
Class - 8 Kips Logix Computers Solutions Class - 12 NCERT Computer Science Solutions
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 14/15
5/20/24, 1:32 PM Chapter 6: Input in Java | Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | KnowledgeBoat
https://www.knowledgeboat.com/learn/class-10-logix-icse-computer-applications-java-bluej/solutions/D5lqZ/input-in-java 15/15