Overview Language Fundamentals Identifiers - A name in Java Program is called an Identifier. Which can be used for identification purpose. It can be method name, or variable name of class name or label name. The characters allowed in an identifier are A-Z, a-z, 0-9, _ and $. Rest other characters will give you a compile time error. An identifier must not start with a digit. An identifier is case sensitive and it can have n number of characters. Reserved Words - There are 53 reserved words available in Java. Keywords (50) Used Keywords (48) Data types byte short int long float double char boolean Conditions if else switch case default do while for break continue return Modifiers public private protected static final abstract synchronized native transient volatile strictfp Exception try catch finally throw throws assert Class class interface extends implements package import Object new instanceof super this Return type void Unused Keywords (2) - goto and const Reserved Literals ...
Overview Array An Array is an indexed collection of fixed number of Homogenous data elements. The main advantage of arrays is we can represent multiple values by using single variable so that readability of the code will be improved. Limitations of Arrays Arrays are fixed in size i.e. once we create an array there is no chance of increasing or decreasing the size based on our requirement. Due to this, to use arrays concept compulsory we should know the size in advance which may not be possible always. Array can hold only homogenous data type elements. Student[] students = new Student[ 1000 ] ; students[ 0 ] = new Student( "Vim Payne" , 18 , 20 , 540 ) ; /* Prompts a compile time error: Incompatible types found: Teacher required: Student */ students[ 1 ] = new Teacher( "Vim Payne" , 18 , "St. Theressa School" , "9A" ) ; We can solve the above problem by using Object type arrays. Object[] students = new Object[ 1000 ] ; students[ 0 ] = new...
Overview Q&A Whenever we are creating a Child class object whether Parent class object will be created or not? Whenever we are creating Child class object automatically Parent constructor will be executed to perform initialization for the instance variables which are inheriting from parent. But it will not create an object of Parent class. It will create the object of only the Child class. Whenever we are creating a Child class object what is the need of executing Parent class constructor? Child class constructor is used to initialize child class properties and Parent class constructor is used to initialize Parent class properties. When you are calling the Child class constructor you have to call Parent class constructor with the help of super keyword. If not the compiler will prompt compile time error. In the below program InterfaceAndAbstractMain both Parent and Child constructor are executed for Child object initialization only. Note: Whenever we are creating Child class ob...
Comments
Post a Comment