Session On Java Basics

by karthikselvakumar

i) Is java purely object oriented language ?

JAVA is not because it supports Primitive datatype such as int, byte, long… etc, to be used, which are not objects.

ii) Write once run anywhere concept ?

Java source code is compiled into class file . This file is executed on any platform which has JVM

iii)  public static void main(String args[])

java environment needs acces to execute it –> public

without creating instance need to run main method   –> static

main method doesnt return anything — > void

all arguments passed are of string type and placed in a string array  –> args[]

iv) diff between == and .equals()

== compare reference

.equals compares the content

v) Access specifier a quick play

public , private protected , default

vi) final , finally and finalize

final – to declare constants and avoid inheriting a class

finally – in exception handling to run a piece of code even exception occurs or not

finalize – whenever garbage collection is about to occur finalize method will be called

vii) java API swing , applets , servlets

viii) no global variable in java ?

referential transparency

namespace collision

ix) Numeric promotion

after any arithmetic operation  (byte,char,short)–>int–> long–>double

x) first argument of args[] in C and java

in C first argument will be the name of the program but in java it is the first argument passed

xi) library methods stringtokenizer

StringTokenizer st=new StringTokenizer(“karthik:be:cse”,”:”,false);


print(st.nextToken()); {

points about java :

* No pointers –  Unauthorized access prevention

* No operator overloading – ambiguity is possible

* No destructor – instead finally is present

* Multithreading made thro language – concurency

* new to allocate memory to object … memory release done by garbage collector