Core Java
Language fundamentals
Agenda :
1. identifiers
2. Reserved word
3.Data Types
4. Literals
5. Array
6. Types of Variables
7. var-arg method
8. main method
9. command line arguments
10. java coding standard
======================================================
1. Identifiers : a name in java program is called identifier which can be used for identification purpose.it can be method name, class name, variable name or label name.
class Test
{
public static void main(String args[])
{
int x=10;
}
}
Q1. how many identifiers?
Answer : 5
Rules for defining java identifiers
1. the only allowed characters are - A to Z , a to z, 0 to 9, $ , _
total_number ?
total# ?
2. identifiers cant start with digit
total123 ?
123total ?
3. java identifiers are case sensitive (java language is case sensitive)
int number =10
int Number =20
int NUMBER =30
4.there is no length limit for java identifier but it is not recommended to take too lengthy identifier
5 we cant use reserve words as identifiers
int x =10 ?
int if =20 ?
6. all predefined class name and interface name can be used as identifier but it is not recommended.
Which of the following valid java identifiers?
total_number
total#
123total
total123
ca$h
_$_$_$
all@hands
java2Share
Integer
Int
int
=====================================================
Reserve words(53)
in java some words are reserved to represent some meaning or functionality , such type of words are called reserved words.
3 Literals (true , false , null)
50 keywords- used 48 unused (goto,const)
keywords for data types
1. byte
2. short
3. int
4. long
5. float
6.double
7. boolean
8. char
keywords for flow control
if
else
switch
case
default
while
do
for
break
continue
return
keywords for modifiers
public
private
protected
static
final
abstract
synchronized
native
strictfp
transient
volatile
keywords for exception handling
try
catch
finally
throw
throws
assert
class related keywords
class
interface
extends
implements
package
import
object related keywords
new
instanceof
super
this
return type keyword
void
"in java return type is mandatory if a method wont return anything then we have to declare that method with void return type.
but in c language return type is optional and default return type is int"
unused keywords
goto
const
reserved literal
true
false
null
enum keyword - we can use enum for named constant
Conclusion - only lowercase , only alphabets
Which list contain valid java identifiers?
new, delete
goto, constant
break , continue, return,exit
final, finally,finalize
throw, throws , thrown
notify, notifyAll
implements, extends, imports
sizeof, instanceof
instanceOf,strictFp
byte,Short,Int
Which of the following are java reserved words
public
static
void
main
String
args
None of the above
Comments
Post a Comment