Fundamentals of Java
Fundamentals of Java
Fundamentals of java
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
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
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
Operators
Punctuators / Separators
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.
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
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:
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) 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
Answer: Modularity
PRACTICE QUESTION
Ques8. Radio buttons are created with the help of ____ class.
PRACTICE QUESTION
Answer: JRadioButton
PRACTICE QUESTION
Answer: True
PRACTICE QUESTION
Answer: True
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
Answer:
The Radio Button component is used to provide the choices to the user
and allow him to select any one choice.
THANK
YOU!!!!!