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

Fundamentals of Java

The document provides an overview of Java fundamentals, including the NetBeans IDE, components, and object-oriented programming concepts. It covers Java features, data types, variables, and selection statements, along with practice questions for reinforcement. Key concepts such as encapsulation, inheritance, and polymorphism are also discussed.

Uploaded by

mostlyme2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Fundamentals of Java

The document provides an overview of Java fundamentals, including the NetBeans IDE, components, and object-oriented programming concepts. It covers Java features, data types, variables, and selection statements, along with practice questions for reinforcement. Key concepts such as encapsulation, inheritance, and polymorphism are also discussed.

Uploaded by

mostlyme2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

UNIT-5

Fundamentals of java

-Bhavya Jain, Akshara Gupta


XI-F
1
NETBEANS IDE
NetBeans IDE, by Apache, is a free, open-source tool for
programming. It supports languages like Java, C++, PHP, and
HTML. It includes a GUI (Graphical use interface) builder for
creating mobile, desktop, and web apps with drag-and-drop
controls.

FUNDAMENTALS OF JAVA
2
FEATURES OF NETBEANS IDE
• Embedded compiler and debugger.
• Auto-completion of code.
• Editing and debugging are easier.
• Syntax highlighting feature is there
• Easy to use.

FUNDAMENTALS OF JAVA
3
4
COMPONENTS
FUNDAMENTALS OF JAVA

• Components are the basic interface elements the user interacts with, Components
1 are placed on a container like jFrame
There are two types of components-:

• Parent or container control: they act as a background for other controls. All the
2 child controls are placed in it. For exp- Frame

• Child controls: controls placed inside a container control are called child control.
3 For exp- Text Field, Label, Button etc.
5
COMPUTER LANGUAGES
A computer does not understand
FUNDAMENTALS OF JAVA

the instructions given in a


First
normal spoken language, it has
to be given instructions in any Low level language (LLL)
computer language i.e a
programming language. The
programming languages can be Second
categorized into the following High-level language (HLL)
two types of languages:
6

POP AND
OOP
APPROACH
7

POP AND
OOP
APPROACH
8
BASIC CONCEPTS OF OOP APPROACH

Class Object
An object is the basic unit of
A class is defined as a collection object-oriented programming
of objects or a blueprint to and corresponds to things or
create objects entities that are related to a
particular class.

FUNDAMENTALS OF JAVA
9
BASIC CONCEPTS OF OOP APPROACH

*Attribute
The characteristics that identifies objects are the attributes. For
example, Birds are a class and Parrot, Pigeon, Eagle and Vulture are
the objects of the class Birds, every bird has got some distinguished
features such as Size, Colour, Voice, Flying Speed etc. These features
are called the attributes or the state of that object.

FUNDAMENTALS OF JAVA
10
BASIC CONCEPTS OF OOP APPROACH

Data Abstraction
Data abstraction is a process that involves identifying the essential
features of an object without including the internal details.
Consider an example of television which consists of features like
changing the channel, volume control, ON/OFF switch, etc.

FUNDAMENTALS OF JAVA
11
BASIC CONCEPTS OF OOP APPROACH

Data Encapsulation
The wrapping up of data and functions into a single unit (called class) is known as
Encapsulation.
There are two features of encapsulation:
o It protects the data of a class from accidental manipulation or misuse by the functions
which are outside the class.
o Any changes made in the data and functions of a class do not affect to other classes.

FUNDAMENTALS OF JAVA
12
BASIC CONCEPTS OF OOP APPROACH

Modularity – Polymorphism –
The act of breaking a program Poly which means Many and
into individual components to Morphs which means Forms. It
means the ability to process the
reduce the complexity is called
data in more than one form
modularity.

FUNDAMENTALS OF JAVA
13
BASIC CONCEPTS OF OOP APPROACH

Inheritance–

The process by which one class acquires the properties and functionalities of
another class is called inheritance.

FUNDAMENTALS OF JAVA
14
INTRODUCTION TO JAVA
Java is one of the popular general-purpose object-oriented programming
languages that is used to develop software packages.

CHARACTERISTICS OF JAVA
1. It is high-level and Object-oriented programming language.
2. The codes of java programs are case-sensitive.
3. It is ideally suited for the integration of video, audio, animation and
graphics in the internet environment.
4. It is a platform-independent language.
FUNADAMENTS OF JAVA
15
JAVA PROGRAMMING ENVIRONMENT
Java programs are saved with .java extension.java compliers the code to
generate .class file which contains intermediate format (highly optimized
code) known as bytecode.
When this bytecode is to be run on any other computer , and interpreter is
required which is known as Java Virtual machine (JVM) that translates the
bytecode to machine code or object code.

FUNADAMENTS OF JAVA
16
JAVA TOKENS
FUMDAMENTALS OF JAVA

Java token includes the


A Token is the smallest
following:
individual unit of a java
• Keywords
• Identifier program.
• Literals
• Operators
• Separators
17
JAVA TOKENS
Keywords
FUMDAMENTALS OF JAVA

These are the pre-defined reserved words of any programming language. Each Keyword
has a special meaning. It is always written in lower case. Java provides the following
keywords:
18
JAVA TOKENS
Identifiers
FUMDAMENTALS OF JAVA

They are the fundamental building blocks or units of a program that are used for naming
classes, methods, variables, objects, etc in a program.
Rules for naming a valid java identifiers are as follows:
o It consists of letters, numbers, underscore and dollar sign
o It must not start with a digit
o It is case sensitive
o It cannot contain space
o It does not have the same name as any keyword
19
JAVA TOKENS
Literals
FUMDAMENTALS OF JAVA

It denotes a constant value. Various types of literals are-:


• Character
• String
• Integer
• Floating-Point
• Boolean
20
JAVA TOKENS
FUMDAMENTALS OF JAVA

Operators

- These are the symbols that do computation (calculation) with designated or


given values. They are divided into following groups:
· Unary – It works on a single operand.
· Binary - It works with two operands.
· Ternary - It works with three operands.
21
JAVA TOKENS
Operators
TYPES-:
FUMDAMENTALS OF JAVA
22
JAVA TOKENS
FUMDAMENTALS OF JAVA

Punctuators / Separators

Punctuators are used as marks or separators in a java program

separator <= ; | , | . | ( | ) | { | } | [ | ]
23
DATA TYPES
A data type is used to define the size and type of value that a variable can store.
The Java language is rich in its data types It provides two types of data types:
primitive and non-primitive.

1. Primitive data types – It consists of numeric and floating-point data types.


· Numeric data types - byte, short, int, long
· Floating-point data types- float, double
· Character data types – It is used to store values in the form of characters.
· Boolean data type- It is used to store either true or false value
FUNDAMENTALS OF JAVA
24
DATA TYPES
2. Non-primitive data types –
Non-primitive data types are derived from primitive data types. These
are also known as reference data types. Some of the examples of non-
primitive data types are class, interface, and array.

FUNDAMENTALS OF JAVA
25
VARIABLES
A variable is a storage location on the computer's memory where a particular type of value
can be stored.
There are three types of variables in Java:
· Local variables- A variable that is declared inside the body of a method or a block is known
as the local variable. The local variable is accessible only within the method in which it is
declared.
· Instance variables- A variable that is declared inside the class but outside the body of the
method is known as an instance variable.
· Static variables - A variable that is declared inside a class using the static keyword is
known as a static variable.
FUNDAMENTALS OF JAVA
26
SELECTION STATEMENTS
If statement

'if' statement is a decision-making statement. It is applied in a situation when the


output of expression is True (i.e., Yes), then a course of action or the statement is
executed, otherwise, the course of action or the statement is ignored.

Syntax: if (test expression)


Statement;

FUNDAMENTALS OF JAVA
27
SELECTION STATEMENTS
if-else statement
if else' statement is a decision-making statement. It is applied in a situation when the output of an
expression is True (ie., Yes), then it follows one direction of execution/statement otherwise if it is
False (l.e., No), then it follows the other direction of execution.

Syntax:

if (test expression) True-block statements(s); else

False-block statement(s);
FUNDAMENTALS OF JAVA
28
SELECTION STATEMENTS
Switch statement

Switch is a keyword. It is a built-in multiple decision-making statement. The switch statement tries to match
the value of a given variable (or expression) with a list of values which are attached to the case statement and
when a match is found, the block of statement(s) associated with that case is executed (case is a keyword).

If the value of the expression do not match with any of the case values, then the default statement will be
executed (default is also a keyword). The default statement in switch is optional

FUNDAMENTALS OF JAVA
29
SELECTION STATEMENTS
Switch statement
The syntax of the switch statement is as follows:
switch (expression)
{
case constant 1: statement 1;
case constant 2: statement 2;
case constant 3: statement 3;
….
….
default: default statement;
}
FUNDAMENTALS OF JAVA
PRACTICE
QUESTIONS!!
PRACTICE QUESTION
Ques1. Which of these cannot be used for a variable name in
Java?

a) identifier & keyword


b) identifier
c) keyword
d) none of the mentioned
PRACTICE QUESTION
Answer: c
Explanation: Keywords are specially reserved words that can
not be used for naming a user-defined variable, for example:
class, int, for, etc.
PRACTICE QUESTION
Ques2. Which of the following is not an OOPS concept in Java?

a) Polymorphism
b) Inheritance
c) Compilation
d) Encapsulation
PRACTICE QUESTION

Answer: c
Explanation: There are 7 OOPS concepts in Java. Inheritance,
Encapsulation, Polymorphism, Abstraction, Class, Object,
Modularity .
PRACTICE QUESTION
Ques3. Which of these are selection statements in Java?
a) break
b) continue
c) for()
d) if()
PRACTICE QUESTION

Answer: D
Explanation: Continue and break are jump statements, and for
is a looping statement
PRACTICE QUESTION
Ques4. Java is a _____ programming language
a.Procedure Oriented
b.Object-Oriented
c.Practical
d.All of the above.
PRACTICE QUESTION

Answer: B
PRACTICE QUESTION
Ques5. NetBeans provides various components used to create a
GUI front-end interface like
a. jTextArea
b. jLabel
c.jButton
d. All of the above
PRACTICE QUESTION

Answer: D
PRACTICE QUESTION

Ques6. The act of breaking a program into individual


components to reduce the complexity is called ________ .
PRACTICE QUESTION

Answer: Modularity
PRACTICE QUESTION

Ques7. ___ is also known as GUI builder.


PRACTICE QUESTION

Answer: Design Area


PRACTICE QUESTION

Ques8. Radio buttons are created with the help of ____ class.
PRACTICE QUESTION

Answer: JRadioButton
PRACTICE QUESTION

Ques9. Child controls are placed inside a container control.


True/False
PRACTICE QUESTION

Answer: True
PRACTICE QUESTION

Ques10. NetBeans IDE is a free and open-source product


provided by the Apache Software Foundation.
True/False
PRACTICE QUESTION

Answer: True
PRACTICE QUESTION

Ques11. What is the difference between Parent control and Child


control in NetBeans?
PRACTICE QUESTION
Answer:
There are two different type of control –
a .Parent or container controls - Controls that serve as a parent or
container serve as the backdrop for other controls. Consider Frame. All of
a parent control's child controls are also destroyed when were move it.
All of a parent control's child controls move with it when the parent
control is moved.
b. Child controls - Child controls are controls that are positioned inside a
container control. For instance, a text field, a label, a button, etc.
PRACTICE QUESTION

Ques12. What is Object Oriented Programming Language?


PRACTICE QUESTION
Answer:
Object-oriented programming is known as OOP. While object-oriented
programming involves constructing objects that include both data and
functions, procedural programming involves developing procedures or
functions that perform actions on the data.
PRACTICE QUESTION

Ques13. What are the rules for naming a valid java identifiers?
PRACTICE QUESTION
Answer:
Rules for naming a valid java identifiers are as follows:
o It consists of letters, numbers, underscore and dollar sign
o It must not start with a digit
o It is case sensitive
o It cannot contain space
o It does not have the same name as any keyword
PRACTICE QUESTION

Ques14. Write any four features of NetBeans IDE.


PRACTICE QUESTION
Answer:
NetBeans IDE has the following features:•
• Embedded compiler and debugger
• Auto-completion of code~
• Editing and debugging is easier
• Syntax highlighting feature is there
PRACTICE QUESTION

Ques15. What are the advantages of the POP approach?


PRACTICE QUESTION
Answer:
Ans. Some of the advantages of POP are as follows:
• It is easy to use.
• It has the ability to re-use the same function at different places in the
program without copying it.
• It provides an easier way to keep track of program flow.
• It has the ability to be strongly modular or structured. It needs less
memory to execute.
PRACTICE QUESTION

Ques16. When do we use the Radio Button component?


PRACTICE QUESTION

Answer:
The Radio Button component is used to provide the choices to the user
and allow him to select any one choice.
THANK
YOU!!!!!

You might also like