• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Java » Java Data Type

Why does a byte can represent a character?

By Dinesh Thakur

A computer cannot store characters or integers. Computer can store information in the form of bits and bytes. The bit is a basic unit of information in computer. A bit can only have two values: yes or no, true or false, 1 or 0. [Read more…] about Why does a byte can represent a character?

Scope of a Variable in Java

By Dinesh Thakur

The scope of a variable specifies the region of the source program where that variable is known, accessible and can be used. In Java, the declared variable has a definite scope. When a variable is defined within a class, its scope determines whether it can be used only within the defined class or outside of the class also. [Read more…] about Scope of a Variable in Java

Type Conversion in Java Example

By Dinesh Thakur

Java has a wide variety of data types from which we can choose the suitable for a particular purpose. To operate on variables from two different types of data we have to convert Both types to the same. [Read more…] about Type Conversion in Java Example

Final Variable in Java Example

By Dinesh Thakur

The final modifier indicates that an object is fixed and cannot be changed. When we use this modifier at a class level, it means that the class can never have subclasses. When we apply this modifier to a method, the method can never be overridden. When we apply this modifier to a variable, the value of the variable remains constant. We will get a compile-time error if we try to override a final method or class. We will also get a compile-time error if we try to change the value of a final variable. [Read more…] about Final Variable in Java Example

Java Static Variables Example

By Dinesh Thakur

Static are the members or variables which are defined independently of any object of that class. Static members are the members that can be used by itself, without reference to a specific instance. We can declare both methods and variables to be static. The variables declared as static are global variables. When objects of the class are declared, no copy of a static variable is made. Instead, all instances of the class share the same static variable. [Read more…] about Java Static Variables Example

Final Variable (OR Constant Variable) in Java with Example

By Dinesh Thakur

Variables are useful when you need to store information that can be changed as program runs. However, there may be certain situations in the program in which the value of variable should not be allowed to modify. This is accomplished using a special type of variable known as final variable. The final variable also called constant variable. It is a variable with a value that cannot be modified during the execution of the program. [Read more…] about Final Variable (OR Constant Variable) in Java with Example

Type Casting in Java Example

By Dinesh Thakur

Type casting is the process of “casting”(Casting mean ‘conversion’ of value to another type) of value to one type to another type of variable. [Read more…] about Type Casting in Java Example

Volume of a Sphere in Java Example

By Dinesh Thakur

In Volume of a Sphere in Java Example , Math.PI is used because it denotes the value of pi i.e. 3.1414. Math.pow(r,3.0) is used for computing y3 [Read more…] about Volume of a Sphere in Java Example

Java Escape Sequences Examples

By Dinesh Thakur

Sometimes you have to work with characters that are not listed on the keyboard or with characters that have a special meaning, as symbol as a “newline.” They can not be displayed directly in the source the program code, and to use them we need special techniques that will look at now. [Read more…] about Java Escape Sequences Examples

Find out the ASCII value from character in Java Example

By Dinesh Thakur

step 1: Read a character

step 2: Cast it into byte and store in b

step 3: Print b

step 4: Exit [Read more…] about Find out the ASCII value from character in Java Example

Non-Static Block in Java Example

By Dinesh Thakur

When the block is declared without using any modifier, then it is treated as the non-static block is first executed before the constructor is executed. Non-static block directly access the static variable and instance variable. [Read more…] about Non-Static Block in Java Example

Static Variable in Java Example

By Dinesh Thakur

The static modifier is associated only with methods and variables, not classes. The static modifier is used to specify variables that can only be declared once. Static methods are used to specify methods that should not be overridden in subclasses. [Read more…] about Static Variable in Java Example

Instance Variable in Java Example

By Dinesh Thakur

1. When the variable is declared outside the method, block, and constructor without using any modifier then it is treated as instance variable.
2. If the instance variable is not initialized then it takes the default value of the data type when the object is constructed.
3. Instance variable can use any access specifier.
4. It is accessed within the static method through the object of the class and within the non-static method and constructor directly without creating any object within the class, but outside the class non-static method and constructor invoke instance variable through objects.
5. Instance variable is also known as object level variable as for every instance the value of instance variable is newly initialized. [Read more…] about Instance Variable in Java Example

Local Variable in Java Example

By Dinesh Thakur

  1. When the variable is declared within the method, block and constructor then the variable is treated as local variable.
  2. Local variable must be initialized before you call it otherwise it generates compile time error.
  3. Same local variable can be declared in two different blocks.
  4. Local variable never use any access specifier. It only takes the default access specifier.
  5. Local variable can never be declared through any access specifier except default access specifier.

[Read more…] about Local Variable in Java Example

Java Byte Example

By Dinesh Thakur

This Java byte Example shows how to use Java primitive byte variable inside a java class. The byte is a 8 bit signed type ranges from –128 to 127. The syntex For Declare byte varibale is byte <variable name> = <default value>; [Read more…] about Java Byte Example

Java Boolean Variable Example

By Dinesh Thakur

This Java boolean Variable Example shows how to use Java boolean variable inside a java class. The boolean data type which can have only two values, true or false. [Read more…] about Java Boolean Variable Example

Convert Int to String Java Example

By Dinesh Thakur

This Convert int to string java example shows how to convert int to String in Java. [Read more…] about Convert Int to String Java Example

Swap Numbers Without Using Third Variable Java Example

By Dinesh Thakur

This Swap Numbers Without Using Third Variable Java Example shows how to exchange numbers without using third variable using java. i.e. if the input is n1 100 and n2 200 then after swaping output will be n1 is 200 and n2 is 100. You should not use any temporary variable to swap the numbers. [Read more…] about Swap Numbers Without Using Third Variable Java Example

Swap Numbers Java Example

By Dinesh Thakur

This Swap Numbers Java Example program prints exchange number i.e. if the input is n1 is 100 and n2 is 200 then after swaping output will be n1 is 200 and n2 is 100. You should use any temporary variable to swap the numbers. [Read more…] about Swap Numbers Java Example

Reverse Number using Java

By Dinesh Thakur

This Reverse Number using Java program prints reverse number using numeric operations i.e. if the input is 564 then output will be 465. we can see after reversing the integer is print the integer digits in reverse order. [Read more…] about Reverse Number using Java

Java Interface Example

By Dinesh Thakur

This JavaInterfaceExample shows, An interface is a blueprint of a class. its functions should be public and abstract. We use the interface Keyword to define an interface. if a class implementing an interface should use the implements keyword as we see in our example class JavaInterface implements InterfaceExample . No need to creating objects for an interface. Interfaces don’t have constructors as they can’t be initiated. An Interface can be extends by one or more interfaces. [Read more…] about Java Interface Example

Java Factorial Using Recursion Example, Java Recursion Factorial Example

By Dinesh Thakur

This JavaFactorialUsingRecursion Example shows shows how to generate factorial of a given number using recursive function. Recursive are the function which calling method itself. the java recursion factorial example demonstrate recursive function call to find factorial. In mathematics, factorial is defined as n! = n*(n-1)…2*1. e.g. If we want to calculate factorial of 10 , then its factorial value is (10*9*8*7*6*5*4*3*2*1) = 3628800. [Read more…] about Java Factorial Using Recursion Example, Java Recursion Factorial Example

Factorial Program in Java

By Dinesh Thakur

This Java Factorial Example shows how to finds factorial of a given number using Java. Entered number is checked first if its negative then an error message is printed. [Read more…] about Factorial Program in Java

Find Largest and Smallest Number in an Array Using Java Example

By Dinesh Thakur

In the Following example LargestandSmallestnumber shows how to Find Largest and Smallest Number in an Array Using Java Example [Read more…] about Find Largest and Smallest Number in an Array Using Java Example

Java Program to Find Odd or Even Numbers | Java Examples

By Dinesh Thakur

In the Following example OddorEvenNumbers use mod operator to check if the number is even or odd. If the number divided by 2 and the reminder is 0 then number is even, otherwise the number is odd.

Here is the java code for the program OddorEvenNumbers :

[Read more…] about Java Program to Find Odd or Even Numbers | Java Examples

Calculate Rectangle Area Using Java Example

By Dinesh Thakur

In the Following example AreaofRectangleExample shows how to Calculate Area of Rectangle is length * width.

[Read more…] about Calculate Rectangle Area Using Java Example

Calculate Circle Perimeter Using Java Example

By Dinesh Thakur

In the Following example PerimeterofCircleExample shows how to Calculate Perimeter of Circle using 2*pi*r. where r is a radius of a circle.

[Read more…] about Calculate Circle Perimeter Using Java Example

Area of Circle Example in Java

By Dinesh Thakur

In the Following example AreaofCircleExample shows how to Calculate Area of Circle using pi*r*r. where r is a radius of a circle.

[Read more…] about Area of Circle Example in Java

Primitive Data Types in Java | Java Primitive Types

By Dinesh Thakur

Java’s built-in data types called primitive types. The java primitive types are int, byte, short, long, float, double, char, and boolean. A variable of any of these data types is called a primitive variable. We explain primitive data types in more detail as follows: [Read more…] about Primitive Data Types in Java | Java Primitive Types

Java Operators – Explain Operator in Java

By Dinesh Thakur

Operator is a symbol that represents some operation that can be performed on data. The operators are applied to operands (onto which processing is desired). These operands can be literals, variables etc. The operators supported by Java are as follows: [Read more…] about Java Operators – Explain Operator in Java

Next Page »

Primary Sidebar

Java Tutorials

Java Tutorials

  • Java - Home
  • Java - IDE
  • Java - Features
  • Java - History
  • Java - this Keyword
  • Java - Tokens
  • Java - Jump Statements
  • Java - Control Statements
  • Java - Literals
  • Java - Data Types
  • Java - Type Casting
  • Java - Constant
  • Java - Differences
  • Java - Keyword
  • Java - Static Keyword
  • Java - Variable Scope
  • Java - Identifiers
  • Java - Nested For Loop
  • Java - Vector
  • Java - Type Conversion Vs Casting
  • Java - Access Protection
  • Java - Implicit Type Conversion
  • Java - Type Casting
  • Java - Call by Value Vs Reference
  • Java - Collections
  • Java - Garbage Collection
  • Java - Scanner Class
  • Java - this Keyword
  • Java - Final Keyword
  • Java - Access Modifiers
  • Java - Design Patterns in Java

OOPS Concepts

  • Java - OOPS Concepts
  • Java - Characteristics of OOP
  • Java - OOPS Benefits
  • Java - Procedural Vs OOP's
  • Java - Polymorphism
  • Java - Encapsulation
  • Java - Multithreading
  • Java - Serialization

Java Operator & Types

  • Java - Operator
  • Java - Logical Operators
  • Java - Conditional Operator
  • Java - Assignment Operator
  • Java - Shift Operators
  • Java - Bitwise Complement Operator

Java Constructor & Types

  • Java - Constructor
  • Java - Copy Constructor
  • Java - String Constructors
  • Java - Parameterized Constructor

Java Array

  • Java - Array
  • Java - Accessing Array Elements
  • Java - ArrayList
  • Java - Passing Arrays to Methods
  • Java - Wrapper Class
  • Java - Singleton Class
  • Java - Access Specifiers
  • Java - Substring

Java Inheritance & Interfaces

  • Java - Inheritance
  • Java - Multilevel Inheritance
  • Java - Single Inheritance
  • Java - Abstract Class
  • Java - Abstraction
  • Java - Interfaces
  • Java - Extending Interfaces
  • Java - Method Overriding
  • Java - Method Overloading
  • Java - Super Keyword
  • Java - Multiple Inheritance

Exception Handling Tutorials

  • Java - Exception Handling
  • Java - Exception-Handling Advantages
  • Java - Final, Finally and Finalize

Data Structures

  • Java - Data Structures
  • Java - Bubble Sort

Advance Java

  • Java - Applet Life Cycle
  • Java - Applet Explaination
  • Java - Thread Model
  • Java - RMI Architecture
  • Java - Applet
  • Java - Swing Features
  • Java - Choice and list Control
  • Java - JFrame with Multiple JPanels
  • Java - Java Adapter Classes
  • Java - AWT Vs Swing
  • Java - Checkbox
  • Java - Byte Stream Classes
  • Java - Character Stream Classes
  • Java - Change Color of Applet
  • Java - Passing Parameters
  • Java - Html Applet Tag
  • Java - JComboBox
  • Java - CardLayout
  • Java - Keyboard Events
  • Java - Applet Run From CLI
  • Java - Applet Update Method
  • Java - Applet Display Methods
  • Java - Event Handling
  • Java - Scrollbar
  • Java - JFrame ContentPane Layout
  • Java - Class Rectangle
  • Java - Event Handling Model

Java programs

  • Java - Armstrong Number
  • Java - Program Structure
  • Java - Java Programs Types
  • Java - Font Class
  • Java - repaint()
  • Java - Thread Priority
  • Java - 1D Array
  • Java - 3x3 Matrix
  • Java - drawline()
  • Java - Prime Number Program
  • Java - Copy Data
  • Java - Calculate Area of Rectangle
  • Java - Strong Number Program
  • Java - Swap Elements of an Array
  • Java - Parameterized Constructor
  • Java - ActionListener
  • Java - Print Number
  • Java - Find Average Program
  • Java - Simple and Compound Interest
  • Java - Area of Rectangle
  • Java - Default Constructor Program
  • Java - Single Inheritance Program
  • Java - Array of Objects
  • Java - Passing 2D Array
  • Java - Compute the Bill
  • Java - BufferedReader Example
  • Java - Sum of First N Number
  • Java - Check Number
  • Java - Sum of Two 3x3 Matrices
  • Java - Calculate Circumference
  • Java - Perfect Number Program
  • Java - Factorial Program
  • Java - Reverse a String

Other Links

  • Java - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2025. All Rights Reserved.

APPLY FOR ONLINE JOB IN BIGGEST CRYPTO COMPANIES
APPLY NOW