Unit 2 - Introduction To Java - Solutions For Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs - KnowledgeBoat
Unit 2 - Introduction To Java - Solutions For Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs - KnowledgeBoat
Contents
Question 1
Question 2
Question 3
Question 4
Question 5
Question 1
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 1/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
Question 2
In Java, the package used to find power raised to any base is java.lang.
Clarification: Math class inside java.lang package contains Math.pow that is used to find power
raised to any base. The official documentation is provided here.
It should not be confused with java.math package which contains BigDecimal, BigInteger and
MathContext classes.
Question 3
The words which are preserved with the system are called keywords/reserved words, that can not
be used as variable names in Java programming.
Question 4
Question 5
Question 1
James Gosling developed Java programming language. It was initially called Oak.
Question 2
In 1991, at Sun Microsystems, Green team led by James Gosling started working on a new
technology for consumer electronic devices. Over the next 18 months, in 1992 the team created
a new programming language which they called “Oak”. By 1994 the team refocussed their
efforts towards internet programming with Oak as it didn't find much traction in consumer
electronics space. Oak was renamed to Java and on 23rd of May 1995, Sun microsystems made
its first public release.
Question 3
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 2/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
Question 4
(a) A compiler
(b) An interpreter
An interpreter is a program that reads a source program line by line, converts each line into its
equivalent machine code and executes it. As it reads the program line by line so the errors are
reported one by one.
Java compiler converts Java source code into an intermediate binary code called Bytecode.
Bytecode can't be executed directly on the processor. It needs to be converted into Machine
Code first.
Question 5
Java Virtual Machine (JVM) is a software that takes Bytecode as input, converts it into Machine
code of the specific platform it is running on and executes it. JVM is platform specific, each
platform has its own JVM.
Question 6
1. java.lang
2. java.io
3. java.util
Question 7
In Java, a reserved word is a word that has a predefined meaning in the language. Due to this,
reserved words can’t be used as names for variables, methods, classes or any other identifier.
Reserved words are also known as keywords. Five commonly used Java reserved words are:
1. public
2. class
3. int
4. double
5. char
Question 8
Distinguish between:
Compiler Interpreter
It translates the whole source program into It translates the source program into target
target program at once. program one line at a time.
All the errors found during compilation are Errors are displayed line by line as each line
displayed together at once. is translated and executed.
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 4/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
JDK includes tools like Compiler, Interpreter, BlueJ provides tools like Code Editor,
Java libraries, etc. Debugger, Syntax Highlighting, etc.
Question 9
A compiler translates a source program written in some high-level programming language into
a target program in another low-level programming language. As low-level programming
languages are platform specific hence a compiler is specific to a language.
Question 10
Question 11
What is BlueJ?
BlueJ is an integrated development environment for Java. It was created for teaching Object
Oriented programming to computer science students.
Question 12
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 5/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
3. It supports syntax highlighting. (Syntax highlighting means showing the different tokens of
the program like keywords, variables, separators, etc. in different colours so that they show
up more clearly.)
4. It facilitates easier debugging as lines causing compilation errors are marked clearly and
the error is displayed at the bottom of the window.
5. It provides a code editor, compiler and debugger integrated into a single tool.
Question 13
java.lang
Question 14
What are the points to be taken care while naming a class in a Java program?
A class name should be a valid Java identifier i.e. it should follow the below three rules:
1. Name of the class should be a sequence of alphabets, digits, underscore and dollar sign
characters only.
2. It should not start with a digit.
3. It should not be a keyword or a boolean or null literal.
Question 15
Java is case sensitive means that it distinguishes between upper case and lower case characters.
Consider the below code snippet:
int studentMarks;
StudentMarks = 85;
This will give a compilation error as Java will treat studentMarks and StudentMarks as two
different variables because the case of the characters is not same in both.
Question 16
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 6/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
public — The public keyword is an access specifier. It controls the visibility of class members.
We can access public class members outside the class where we declare them. We need to
make the main method public because it will be called by code outside of its class when the
program is started.
static — When we declare a method inside a class as static, we can call it without creating the
object of that class. We need to make the main method static because Java Virtual Machine
(JVM) will call it to start the program even before any objects of the class are created.
void — The void keyword tells the compiler that the main method will not return any value.
Question 17
The process of converting a source program written in some high-level programming language
into a target program in another low-level programming language without changing the
meaning of the program is called Compilation.
Question 18
Java compiler compiles Java source code to Bytecode. Bytecode cannot run on the processor
directly as processor only understands Machine Code. Java Virtual Machine (JVM) takes this
Bytecode as input and converts it into Machine Code line by line. So, JVM acts as an interpreter
for converting Bytecode to Machine Code. In this way, a Java program uses both a Compiler as
well as an Interpreter to get executed on the processor.
Question 19
Design a program in Java to display the following information on the output screen:
Name:
Class:
Roll No.:
Subject:
School:
Answer
class StudentInfo {
public static void main(String args[]) {
System.out.println("Name: Akshay Anand");
System.out.println("Class: 10");
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 7/9
7/13/2020 Unit 2: Introduction to Java | Solutions for Class 9 ICSE APC Understanding Computer Applications With BlueJ Including Java Programs …
Question 20
You want to display your bio-data on the output screen. Write a program in Java to perform the
task in the given format:
Name:
Father's Name:
Date of birth:
Blood Group:
Aadhar Card No.:
State:
Answer
class BioData {
public static void main(String args[]) {
System.out.println("Name: Shweta Nayak");
System.out.println("Father's Name: Arvind Nayak");
System.out.println("Date of birth: 12/12/2005");
System.out.println("Blood Group: O+");
System.out.println("Aadhar Card No.: 4321 8756 9978");
System.out.println("State: Karnataka");
}
}
Video Explanations
https://www.knowledgeboat.com/learn/class-9-icse-understanding-computer-applications-bluej/solutions/l7Xn3/introduction-to-java 8/9