Skip to main content

Posts

Showing posts from March, 2021

Data Types in Java

Every variable has a type, every expression has a type and all types are strictly define moreover every assignment should be checked by the compiler by the type compatibility hence java language is considered as strongly typed programming language. Integral data types:- byte: Size: 1 byte (8 bits) Range:  -128 to 127 byte data type is best suitable if we are handling data in terms of streams either from the file or from the network. short: The most rarely used data type in Java is short. Size: 2 byte Range: -32768 to 32767 short data type is best suitable for 16-bit processors like 8086 but these processors are completely outdated and hence the corresponding short data type is also out data type. int: Size: 4 byte Range: -2147483678 to 2147483647 long: Whenever int is not enough to hold big values than we should go for long data type. Size: 8byte Range: -263 to 263-1 All the data types (byte, short, int, and long) can be used to represent whole numbers. If we want to represent real num

Java Reserved Words

  Java Reserved Words   In java, some identifiers are reserved to associate some functionality or meaning such type of reserved identifiers is called reserved words. > Reserved words for data types (8) byte short int long float char double boolean > Reserved words for flow control (11) if else switch case default for do while break continue return > Keywords for modifiers (11) public private protected static final abstract synchronized native strictfp (1.2 version) transient volatile > Keywords for exception handling (6) try catch finally throw throws assert (1.4 version) > Class related keywords (6) class package import extends implements interface > Object related keywords (4) new super instanceof this > Void return type keywords: If a method won't return anything compulsory that method should be declared with the void return type in java but it is optional in C++ void > Unused keywords : goto: Create several problems in old languages and hence it i