Skip to main content

Posts

Showing posts from 2020

Array

Introduction:                         An array is an index collection of a fixed number of homogeneous data elements.          The main advantage of the array is, we can represent a huge number of values using a single variable. So, the readability of the code will be improved.          But the main disadvantage of an array is, fixed in size. i.e. Once we create an array there is no chance of increasing or decreasing the size based on our requirement. Hence, to use the array concept compulsory we should know the size in advance, which may not possible always. Array Declaration:                             There are three ways to declare the one-dimensional array. They are as follows                                   int[] x;                                   int []x;                                   int x[]; All above are valid, but int[] x; is recommended, because variable name clearly separated from the type of array.                    At the time of declaration, we can't spec

Literals

Literals:                 Any constant value which can be assigned to the variable is called literal.     1 . Integer Literals:                                        For integral data types ( byte, short, int, long ), we can specify a literal value in the following base...                         a) Decimal literal (base 10):                                                     Allowed digits are 0 to 9.                                                                e.g.  int x = 10;                         b) Octal literal (base 8):                                                 Allowed digits are 0 to 7.                                             Literal should be prefixed with '0' (Zero).                                                       e.g.   int x = 010;                         c) Hexa decimal literal (base 16):                                                   Allowed digits are 0 to 9, a to f. For extra digits (a to f), we can use both lowercase and uppercase c

Data Types

Data Types:                         In java, Every variable and every expression has some type. Each and every data type is clearly defined. Every assignment should be checked by the compiler for data compatibility.                              Because of the above reason, we can conclude, Java language is strongly typed programming language. Que :-  Is java pure object-oriented programming language? Ans :- Java is not considered as the pure object-oriented programming language, because several oop features are not satisfied by java (like operator overloading, Multiple inheritances, etc.).               Moreover, we are depending on primitive data types, which are non-objects. Except for boolean and char, remaining data types are considered as signed data types. Because we can represent both positive and negative numbers. byte:                                  Size: 1 byte ( 8 bits )                             Max value: 127                                   Min value: -128          

Reserved words

Reserved Words:                                    In java, some words are reserved to represent some meaning or functionality such types of words are called reserved words. Data type related keywords:                     1. byte                         2. short                         3. int                         5. long                         6. float                         7. double                         8. char Flow control-related keywords:                     1. if                         2. else                         3. switch                         4. case                         5. default                         6. do                         7. while                         8. for                         9. continue                         10. return                         11. break Modifiers related keywords:                     1. public                         2. private                         3. protected                         4. static