Skip to main content

Posts

Showing posts from February, 2023

Operators & Assignment part 3

                                                                                       Operators & Assignment 1-:instanceof Operators 2-:Bitwise Operators                                                                        instanceof Operators we can use instanceof operator to check whether the given object is of a particular type are not. Example-: /* list is a collection of objects. List l=new List(); l.add(Customer); l.add(Student); l.add(Test); Object o=l.get(...

Assignment operator part 2

                                                    Operator & Assignments 1-:String Concatination Operator(+) 2-:Relational Operators(>,>=,<,<=) 3-:Equality Operators(==,!=)                                                     String Concatenation operator  The only overloaded operator in java is (+) operator some time it accesses arithmetic addition operator some time it access String concatenation operator. if at least one argument is String Type then + operator access concatenation operator and if both arguments are Number type then + operator access arithmetic addition operator. Example-: ...

Error in variable Declaration

  All declaration problem If int greater than size we got error-> error: integer number too large     int x=2147483648; error: integer number too large     int x=-2147483649; error: incompatible types: boolean cannot be converted to int     int x=true; error: incompatible types: int cannot be converted to boolean     boolean x=10; error: incompatible types: possible lossy conversion from double to long   long x=10.88; error: cannot find symbol     boolean x=True;               ^   symbol:   variable True : error: incompatible types: int cannot be converted to boolean   if(x){       ^ : error: incompatible types: int cannot be converted to boolean   while(x){ Above the last both error valid in c and C++ but error in java Size of char in java 2 byte because java is unicode based but c and c++ are ascii code based language System...

Variables

                                                          Variables Variables in Java are classified into primitive and reference variables. From the programmer's perspective, a primitive variable's information is stored as the value of that variable, whereas a reference variable holds a reference to information related to that variable. reference variables are practically always objected in Java. Let's take a look at both of these types with the help of two examples.   Tow type of variable. 1-: primitive variable /* int x=10;  byte b=20; short a=30; char c='a'; */   Can be used to represent primitive values in above the example 2-: reference variable Can be used to refer objects example-: /* Student s=new Student(); */ Based on position of declaration a...