Chapte 1 Exercises Unit II Introduction to JAVA
Chapte 1 Exercises Unit II Introduction to JAVA
Question 1
Java application is a Java program which is developed by users.
True
Question 2
James Gosling developed Java programming language.
True
Question 3
Machine codes are expressed using alphanumeric characters.
False
Question 4
Byte code is the program in binary form.
True
Question 5
JVM is Java Visual Management.
False
Page | 1
UMESH COMPUTER KENDRA (PH : 9897188951)
Fill in the blanks with appropriate words
Question 1
Question 2
In Java, the package used to find power raised to any base
is java.lang.
Question 3
The words which are preserved with the system are
called keywords/reserved words, that cannot be used as variable
names in Java programming.
Question 4
A single line comment is represented by the symbol // in Java
programming.
Question 5
Question 1
Page | 2
UMESH COMPUTER KENDRA (PH : 9897188951)
Question 2
Give a brief historical development of Java.
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”. Oak was
renamed to Java and on 23rd of May 1995, Sun microsystems
made its first public release.
Question 3
Question 4
(a) A compiler
A compiler is a program that translates 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. The compiler processes the complete
Page | 3
UMESH COMPUTER KENDRA (PH : 9897188951)
source program at once and if there are compilation errors, they
are all reported together at once.
(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.
(c) Byte code
Question 5
What is Java Virtual Machine (JVM)?
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.
Question 6
1. java.lang
2. java.io
3. java.util
Question 7
Page | 4
UMESH COMPUTER KENDRA (PH : 9897188951)
What are Java reserved words? Name any five.
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: public, class, int, double, char
Question 8
Distinguish between:
Compiler Interpreter
Page | 5
UMESH COMPUTER KENDRA (PH : 9897188951)
Compiler Interpreter
All the errors found during Errors are displayed line by line
compilation are displayed as each line is translated and
together at once. executed.
Question 9
Question 11
What is BlueJ?
Page | 7
UMESH COMPUTER KENDRA (PH : 9897188951)
BlueJ is an integrated development environment for Java. It was
created for teaching Object Oriented programming to computer
science students.
Question 12
Question 13
Name a package that is invoked by default.
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:
Question 16
The main function in a Java program is declared as:
public static void main (String args[])
What is the significance of the words public, static and void?
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.
Question 17
Page | 9
UMESH COMPUTER KENDRA (PH : 9897188951)
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 program uses compiler as well as interpreter. Explain.
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 Info
{
public static void main()
{
Page | 10
UMESH COMPUTER KENDRA (PH : 9897188951)
System.out.println("Name: Mudit Garg");
System.out.println("Class: 9");
System.out.println("Roll No.: 5");
System.out.println("Subject: Computer");
System.out.println("School: St. Peter College");
}
}
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
{
void main()
{
System.out.println("Name: Amit Sharma");
System.out.println("Father's Name:Yash Sharma");
System.out.println("Date of birth: 12/12/2005");
System.out.println("Blood Group: B+");
System.out.println("Aadhar Card No:432187569978");
System.out.println("State: Uttar Pradesh");
}
}
Page | 11
UMESH COMPUTER KENDRA (PH : 9897188951)