Urgenthomework logo
UrgentHomeWork
Live chat

Loading..

JAVA Data Abstraction

Data Abstraction:

The illustration of essential features without including the background details or explanations is known as abstraction. Using abstract classes or interfaces can hide internal implementation details.

Real time example:

The real life example for abstraction is considering TV remote. When you press any button in remote some functions are processed on TV. For that you no need not know internal work process.

5. Basic Data types

Depends on the data types the memory will be allocated by operating system. There are two types available in the java.

1. Primitive data types – byte, short, int, float, long, double, char

2. Non – primitive data types – string, arrays, class

Primitive data types:

Data Type

Size

Description

Byte

1 byte

from -128 to 127

Short

2 bytes

from -32,768 to 32,767

Int

4 bytes

from -2,147,483,648 to 2,147,483,647

Long

8 bytes

from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

Float

4 bytes

Stores fractional numbers. Enough for storing 6 to 7 decimal digits

Double

8 bytes

Stores fractional numbers. Enough for storing 15 decimal digits

Boolean

1 bit

Stores true or false values

Char

2 bytes

Stores a single character/letter or ASCII values

Example:

{`class Sample
{  ;
public static void main(String[] args)
{  ;
float num1 = 15.68f;
System.out.println(num1);
&};
&};
`}

Output:

15.68

Literals:

It is fixed value that is assign to the variable in the program. There are many literals available using primitive data types.

Example:

Integer literals: Int num1=10;

Character literals: char ch = ‘a’;

Float literals: float num1 =14.5;

Copyright © 2009-2023 UrgentHomework.com, All right reserved.