0% found this document useful (0 votes)
11 views

G-8 ch-5 Introduction to Java and BlueJ

The document provides an introduction to Java programming concepts, focusing on object-oriented principles such as encapsulation, classes, and objects. It explains key terms like identifiers, keywords, and operators, and highlights the differences between classes and objects. Additionally, it discusses the importance of variables and constants in programming, along with practical examples to illustrate these concepts.

Uploaded by

art.work3.omk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

G-8 ch-5 Introduction to Java and BlueJ

The document provides an introduction to Java programming concepts, focusing on object-oriented principles such as encapsulation, classes, and objects. It explains key terms like identifiers, keywords, and operators, and highlights the differences between classes and objects. Additionally, it discusses the importance of variables and constants in programming, along with practical examples to illustrate these concepts.

Uploaded by

art.work3.omk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Introduction to Java and BlueJ

Fill in the
5. The Java programming language is an Object Oriented
Programming language.
6. Encapsulation is the technique of binding both data and functions
together.
7.A Class is a blueprint that defines data and functions common to all
objects of a certain kind.
8. Initialization is a process of assigning some initial value to a
variable.
9.

Answer the following


1.​Define Encapsulation.
Ans: The wrapping up of data and member functions into a
single unit called class is known as encapsulation.
2.​What is Data abstraction? Explain with an example.
Ans: Data abstraction helps in the clear separation
between the abstract properties and the details of its
implementation.
Example:
While driving a car we need to know the basic
operations to drive a car.You need not know the internal
functioning or complex architecture of the car.

3.​ Differentiate between an object and a class?


Ans:

Class Object
1.​ Class is the blueprint of an Object is an instance of a class.
object. It is used to declare and
create objects.
2.​ No memory is allocated when Memory is allocated as soon as an
a class is declared. object is created.
3.​ A class is a group of similar Object is a real-world entity such as
objects a book, car, etc.
.
4.​ Class can only be declared Objects can be created many times
once. as per requirement.

5.​ Examples of class can be cars. Objects of the class car can be
BMW, Mercedes, jaguar, etc.

4. What is an identifier?
Ans : Identifiers in Java are the name of variables, methods, classes,
packages and interfaces.They represent names of different components of a
java program.
5. What are keywords? State the difference between keywords
and identifiers.
Ans: Keywords are the predefined and specific reserved words, which hold
special meaning.
Keyword Identifire

1.​ Keywords are predefined A particular name generated by


and specific reserved the programmer to define a
words, which hold special variable, classes, methods,
meaning. Keywords help in packages and interfaces.
defining any statement in
the program.
2.​ A keyword Consider only In the identifier, Consider
letters. letters, underscore, digits.

Identify the name of a


3.​ Specify the type/kind of particular entity.
entity. First character can be an
uppercase, lowercase letter
4.​It always starts with a or underscore.
lowercase letter.
Test, count1, high_speed,
5.​int, char, if, while, do, etc.
class etc.

6.​ Explain the structure of a Java progra


Ans:

7.​ Define objects. Give a real life example to explain objects along
with their attributes and behaviour.
Ans : An object represents data (attributes) and its related methods
(behaviour) as a single unit. Take the example of a car. When we
describe a car as an object, there are a number of physical factors
which contribute to define its state such as its brand name, colour,
speed, size, number of seats, etc. In addition, the car has several
functional definitions. It transports people to different locations by
controlling its speed and direction, an accelerator to increase or
decrease its speed and brakes to stop it. Thus we can say that car
is an object that combines its attributes and behaviour as a single
unit.

8.​ What is class?

​ Ans: A class is a blueprint to create objects. It defines data and


functions common to all objects of a certain kind.

9.​ What do you understand by the term Polymorphism?

Ans: The word Polymorphism means "many forms". Polymorphism


helps the programmer to use the same function name for more than one
purpose.

10.​ What are operators? Why do we need them?

Ans: Operators are special symbols that are used to perform


calculations. We need operators to form expressions by applying them to
the variables and constants.

11.​ What do you understand by the term Keyword?

Ans:Keywords are reserved words that have a special meaning for the
Java compiler. Java compiler reserves these words for its own use so
Keywords cannot be used as identifiers. For example, void, public, class,
int, etc.

12.​ What are variables? How are they different from Constants?
Ans: A variable is a named location in the memory which stores data
temporarily. A variable has a unique name, a type and a size that is used
to identify it in a program.

Difference between variables and constants is that the value of variables


can change during the execution of the program whereas value of
constants are fixed and does not change during program execution.

👇
Write these two programs in BlueJ editor ,compile it and execute it
and write the output in the given space.

You might also like