0% found this document useful (0 votes)
32 views6 pages

JAVA NOTES FOR Class VIII

The document provides comprehensive notes on Java for ICSE 2024-25, covering Object-Oriented Programming concepts, Java fundamentals, data types, operators, and math functions. It includes definitions, examples, board questions, and explanations of key terms such as API, JVM, and OOP principles. Additionally, it outlines the structure of Java programs, types of comments, and the role of the Java compiler and interpreter.

Uploaded by

teotiaanil1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views6 pages

JAVA NOTES FOR Class VIII

The document provides comprehensive notes on Java for ICSE 2024-25, covering Object-Oriented Programming concepts, Java fundamentals, data types, operators, and math functions. It includes definitions, examples, board questions, and explanations of key terms such as API, JVM, and OOP principles. Additionally, it outlines the structure of Java programs, types of comments, and the role of the Java compiler and interpreter.

Uploaded by

teotiaanil1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

JAVA NOTES FOR ICSE 2024-25

CHAPTER 1
OBJECT ORIENTED PROGRAMMING

I. Name the following.


a. The initial name of Java → Oak
b. The hardware of software environment in which a program executes → Platform.
c. The programs that are embedded in a webpage → Applets

II. Give the fullf orms


a. API - Application Program Interface
b. JVM - Java Virtual Machine
c. IDE - Integrated Development Environment
d. JDK - Java Development Kit
e. OOP - Object Oriented Programming
f. POP - Procedural Oriented Programming
g. WORA - Write Once Run Anywhere
h. JRE - Java Runtime Environment.

III. Define the following .


a. API → Application Program Interface(API) consists of library and
precompiled Codes that programmers can use in their programs.
b. JVM → Java Virtual Machine is the Java Interpreter that converts Byte Code
into Machine Code.
c. JDK → Java Development Kit (JDK) is a collection of tools that are used for
developing and running Java Programs.

Board Questions from this Chapter.


1. Name any two OOP Principles.--> Ans Abstraction and Encapsulation
2. Define abstraction. → Ans Abstraction refers to specifying the behaviour of a class
without going into the details of the implementation.
3. What do you understand by data abstraction? Explain with an example.
Ans. Abstraction refers to representing the essential features of a system without
considering all the details. Example: When we drive a car, we concentrate on how to
drive it without bothering ourselves on how the engine works and other things.
4. Define Encapsulation. Ans. Encapsulation is the process of bundling state (instance
variables) and behaviour (methods) is a single unit (class)
5. What is Inheritance ? Ans. Inheritance is the process by which one class extends
another class to inherit the variables and functions and add any additional variables
and methods.
6. Why is an object called an instance of a class? Ans: Object of a class contains data
and functions provided in a class. it possesses all the features of a class. Hence object
is termed as instance of a class.
7. Write one difference between primitive data types and composite data types.
Ans. A primitive data type is not composed of other data types. Ex: int, float, double
while a composite data type is composed of other data types. Ex: class
8. What does a class encapsulate? Ans. A class encapsulated the data (instance
variables) and methods.

1
9. What is the difference between an object and a class? Ans. 1. A class is a
blueprint or a prototype of a real world object. It contains instance variables and
methods whereas an object is an instance of a class.
2. A class exists in the memory of a computer while an object does not.
3. There will be only one copy of a class whereas multiple objects can be instantiated
from the same class.
10. Why is a class called a factory of objects? Ans. A class is known as a factory of
objects because objects are instantiated from classes. Each object gets a copy of the
instance variables present in the class. It is like a factory producing objects.
11. Why is a class known as a composite data type? Ans. A class is composed of
instance variables which are of different data types. hence, a class can be viewed as a
composite data type which is composed of primitive and other composite data types.

Chapter 2
Introduction to Java

I. Name the following.


a. The set of pseudo-machine language instructions that are understood by the
JVM → ByteCode.
b. Java’s portability can be attributed to what → its Run-time system and its
API.
c. Java programs are Interpreted by the JVM.
d. A Platform is the hardware/software environment in which a program remains.
e. Applets are small programs that remain embedded in a web page and runs on
the viewer’s machine in a secured manner.
II. Name the different Types of Java Programs.
Ans
1) Standalone Application
2) Internet Applets
III. Name the three types of comments in Java Ans :
a. Single Line Comment → // This comment is for one single line
b. Multiline Comment → /* ……
…..*/ For More than one comment.
c. Documentation Comment → /** . . ..
……..*/ For documentation comment
III. Java uses compiler as well as interpreter, explain.
Ans:Java Programs are both Compiled and Interpreted.Java compiler converts
Java source code to byte code. This byte codeis further converted into machine
code to make it applicable for the specific platform by using interpreter.
IV. What do you mean by Byte Code? Ans: Byte Code – is an intermediate code
that consists of a set of pseudo machine language instructions that are understood
by the JVM and are independent of the underlying hardware. It is called byte code
because each chunk of code is of 8 BITS (1 byte = 8 Bits).

Fill in the blanks:


1. Java uses Unicode character set.
2. Unicode is a two bytes character set.
3. Character Set is a set of valid characters that a language can recognize.

2
4. The smallest individual unit in a program is a token.
5. Identifiers are fundamental building blocks that give names to different parts
of a program.
6. Escape sequences/Non graphic characters are characters that cannot be typed
directly from the keyboard.
7. Operators that act upon two operands are referred to as Binary operators.
8. Variables represent named storage locations whose values can be
manipulated during program execution.
9. The new operator is used to allocate memory for objects and arrays.

1. What do you mean by Character Set? Name the characterset of Java?


Ans Character Set is a set of valid characters that a language can recognize. The
character set of Java is UNICODE.
2. What do you mean by Token ? Name the different kind of tokens in Java. Ans.
Tokens are smallest individual units of a Java program. There are 5 different types of
tokens in Java – 1. Keywords 2. Identifiers 3. Literals 4. Operators 5. Separators
Hint: Remember the word KILOS )
3. What do you mean by Escape sequence and name few escape sequences in Java?
Ans: Java have certain nongraphic characters (nongraphic characters are those
characters that can not be typed directly from keyboard e.g. backspace, tab, carriage
return etc.). The few escape sequence characters are: \n for new line, \t for Horizontal
Tab, \v for Vertical Tab, \b for Backspace, \” for Double Quotes etc.
4. What is a type or ‘Data Type’?? Ans: A type or datatype represents a set of possible
values. They are the entities that tell the compiler that which variable will hold what
kind of values. .
5. Name the different types of Data types in Java? Ans The two types of data types in
Java are Primitive Data Type and Non Primitive Data Type.
6. What is primitive data type? Name its different types. Ans: Primitive data types
are pre defined or built in data types because they are already built in java. The
primitive data types in Java are: byte, short, int, long, float, double, char and Boolean.
7. What is Non Primitive data type? Give Eg. . Directly or indirectly dependent on
primitive data types. They store the data values with reference to the address or
locations. So, they are called as Reference Data Types. E.g. array, classes interfaces
etc…
8. How many bytes occupied by the following data types: byte, short, int, long, float,
double, char, boolean. Ans: char-2 byte, byte-1 byte, short-2 bytes, int-4 bytes,
long-8 bytes, float-4 bytes, double-8 bytes, boolean-Java reserve 8 bits but only use 1
bit.
9. What is the range of the following data types: byte, short, int, long, float, double,
char, boolean. Ans: byte -> -128 to 127
short -> -32768 to 32767 int -> -231 to 231-1
long ->-263 to 263-1 float -> -3.4×1038 to 3.4×1038
double -> -1.7×10308 to 1.7×10308 char -> 0 to 65536
boolean – > true or false
10. Show the size in bytes, default value and range of primitive values

3
Range
Size in Default (Smallest and
Primitive Data Type Bytes Value Biggest Value)
byte 1 0 -128 to 127
short 2 0 -32768 to 32767
Integer
int 4 0 −231 to 231−1
Long 8 0L -263 to 263−1
float 4 0.0f - 3.4E+38 to 3.8
Real -1.7E+308 to
double 8 0.0d 1.7E+308
char 2 \u0000 0 to 65535
boolean 1 bit FALSE

11. What do you mean by operator and write the name of all operators given in your
textbook. Ans: Operator – are the entities or symbols that tell the compiler that what
operation has to be performed with one, two or three number of operands within a
given expression.
There are approximately a set of 37 different operators that Java uses
Operators can either operate on 1, 2 or 3 operands and accordingly named as –
Unary (works on 1 operand) e.g. + + and – –
Binary (works on 2 operands) e.g. +, – , * , / , >, <, == etc…
Ternary (works on 3 operands) e.g. ? :
12. Categorize the different types of Operators. Ans The different types of Operators are
Arithmetic Operators (+ , – , * , / , %)
Relational Operators (> , < , >= , <= , == , !=)
Logical Operators (&&, || , !)
Conditional Operators (? : )
are the entities or symbols that tell the compiler that what operation has to be
performed with one, two or three number of operands within a given expression.
13. Explain Maths functions in Java
The Math class belongs to the default package of Java named java.lang)
Math.min(a, b) Returns the smaller among a and b
Math.max(a, b) Returns the larger among a and b
Math.abs(a) Convert -ve magnitude to +ve magnitude.
Math.sqrt(x) Returns the square root of ‘x’
Math.pow(x, y) Returns x to the power of y
Math.cbrt(x) Returns the cube root of ‘x’
Math.floor(x) Returns the integral value of x less than or equal to ‘x’ but datatype
returned is double, hence Math.floor(7.9) will give 7.0
Math.ceil(x) Returns the integral value of x greater than or equal to ‘x’ but datatype
returned is double, hence Math.ceil(7.9) will give 8.0

14. Explain the methods print() and println()?Ans Java supports two output methods
that can be used to send the results to the screen. print() method and println()
method.The print() method prints output on one line. The println() method by contrast
takes the information provided and displays it on a line followed by a line feed.

4
1. a) Which of the following are valid comments?
(i) /* comment */ (ii) /*comment (iii) //comment (iv) */ comment */
Ans: i. and iii.
2. State the two kinds of data types.
Ans: The two types of data types are: Primitive and non-primitive/composite/user define
data types. The primitive data types are: byte, short, int, long, float, double, char and
Boolean. The non-primitive/reference data types are: class, array and interface.
3. Assign the value of pi(0.3174) to a variable with requisite data type
Ans double pi= 0.3174;
4. Name the primitive data type in Java that is:
(i) a 64-bit integer and is used when you need a range of values wider than those
provided by int.-- long
(ii) a single 16-bit Unicode character whose default value is ‘\u0000′ → char
5. Give one example each of a primitive data type and a composite data type.
Ans. Primitive Data Types – byte, short, int, long, float, double, char, boolean
Composite Data Type – Class, Array, Interface
6. Classify the following as primitive or non-primitive data types:
(i) char (ii) arrays (iii) int (iv) classes
Ans. (i) char – Primitive (ii) arrays – Non primitive
(iii) int – Primitive (iv) Classes – Non primitive

7. Arrange the following primitive data types in an ascending order of their size:
(i) char (ii) byte (iii) double (iv) int
Ans. The sizes of the given data types are as follows
char = 2 bytes byte = 1 byte double = 8 bytes int = 4 bytes
Arranging them in ascending order gives byte < char < int < double
8. What is the default of int and float ? Ans int –>0 and float 0.0f
9. State the number of bytes occupied by char and int data types.
Ans. char occupies two bytes and int occupied 4 bytes.
10. State the Java concept that is implemented through:
i) a super class and a subclass. – Inheritance
ii) the act of representing essential features without including background details.
Abstraction
11. Identify the literals listed below : (i)0.5 (ii)’A’ (iii)false (iv)”a”
i. double literal ii. Character literal iii. Boolean literal iv. String literal
12. Identify the following tokens
i. public ii. ‘a’ iii. == iv. { }.
Ans. public → Keyword ‘a’ → Literal == → Operator {} → Separator
13. Write a Java expression for the following:
√(3x + x2) / (a + b) Ans. Math.sqrt(3 * x + Math.pow(x, 2)) / (a + b)
2
|x + 2xy| Ans Math.abs(x * x + 2 * x * y)
5 3
c. ax + bx + c Ans. a * Math.pow(x, 5) + b * Math.pow(x, 3) + c
2
√𝐴 + 𝐵 + 𝐶2 2

Ans Math.sqrt(Math.pow(A,2) + Math.pow(B,2) + Math.pow(C,2))


d. ut + ½ ft2 Ans. u * t + 0.5 * f * Math.pow ( t, 2)
14. What are the values stored in variables r1 and r2:
i) double r1 = Math.abs(Math.min(-2.83,-5.83)); Ans →5.83
ii) double r2 = Math.sqrt(Math.floor(16.3)); Ans →4.0

5
15. Give Output i) Math.ceil(4.2) → 5.0
(ii) Math.abs(-4) ➔ 4
16. Give Output of the following functions.
a) Math.floor(–26.349)→-27.0
b) Math.floor(15.36) →15.0
c) Math.min(–0.0,0.0) -→0.0
d) Math.pow(2,3) →8.0
e) Math.sqrt(625) →25.0
f) Math.cbrt(125)→5.0
g) Math.ceil(–14.0) = -14.0
i) Math.ceil(–12.56) -12.0
j) Math.max(4.6,1.3) 4.6
l) Math.max(11,11) 11
m) Math.min(14.3,14.3) 14.3
17. What is the value of y after evaluating the expression given below?
i. y += ++y + y– + –y; when int y = 8.
Ans. y += ++y + y– + –y y = 8 + ++y + y– + –y
y=8+9+9+7 y = 33

ii. Evaluate the following expression if the value of x = 2, y = 3 and z = 1


v = x + --z + y++ + y; = 2 + 0 + 3 + 4 = 9
iii. What is the value of x1 if x=5 ?
x1=++x – x++ + –x Ans 6
Ans. x1 = 6 (x is incremented to 6) – 6 (x is incremented to 7) + 6 (x is
decremented to 6) = 6
iv. Give the output of the following expression :
a+=a++ + ++a + -–a + a-– ; when a = 7
Ans. a+=a++ + ++a + –-a + a–- ; a = 7 + (a++ + ++a + -–a + a–-);
a = 7 + (7 + 9 + 8 + 8); a = 39
v. int x=4; x+= (x++)+ (++x) +x; Ans 20
vi. Give the output of the following:
int a =5; a++; System.out.println(a); a- =(a--) – (--a);
System.out.println(a);
Ans : 6. 4
18. Give the output of the following:
(i) Math.floor(-4.7) → 5.0
(ii) Math.ceil(3.4) + Math.pow(2, 3) → 12.0
iii. Math.sqrt(Math.max(9, 16)) →4.0

You might also like