You are on page 1of 2

Assignment I

Basics of JAVA
Q-1 Explain why JAVA is known as platform Independent/Neutral Lanuae! "#$%
Q-$ &ow is JAVA stronly asso'iated with the Internet! "#$%
Q-( Explain) "1$%
1* +ethod ,-erloadin
$* .inal /lass
(* .inal Varia0les 1 +ethods
2* A0stra't +ethods 1 /lasses
Q-2 Explain J345 "#$%
Q-6 Explain syntax of main in JAVA and 7hy it is part of 'lass! "#2%
Q-8 Is it ne'essary to ha-e same name of 'lass and sour'e file in JAVA 9roram! "#(%
Assignment II
Packages, Interfaces, Exceptions & Multithreading
Q-1 7hy are arrays easier to use 'ompared to a 0un'h of related -aria0les! "#$%
Q-$ .ind errors: if any: in the followin 'ode sement) "#$%
int m;
int x" % < int "1#%;
int "5%y < int "11%;
for=m<1;m><1#;??m*
x"m% < y"m% < m;
x < y < new int"$#%;
for=m<1;m>1#;??m*
system5out5printn=x"m%*
Q-( &ow does String 'lass differ from the StringBuffer 'lass! "#$%
Q-2 7hat is a -e'tor! &ow is it different from an array! "#$%
Q-6 7hat are appli'ations of wrapper 'lasses! "#$%
Q-8 7hat are differen'es and similarities 0etween an interfa'e and 'lass! "#$%
Q-@ 7hat is a pa'kae! Atate ad-antaes/0enefits of oraniBin 'lasses into pa'kae5 7rite down
steps for desinin/'reatin a pa'kae5 "#2%
Q-C Is the followin 'ode leal! "#1%
try D

E finally D

E
Q-F 7hat ex'eption types 'an 0e 'auht 0y the followin handler! "#1%
'at'h =Ex'eption e* D

E
7hat is wron with usin this type of ex'eption handler!
Q-1# Is there anythin wron with the followin ex'eption handler as written! 7ill this
'ode 'ompile! "#$%
try D
E 'at'h =Ex'eption e* D

E 'at'h =Arithmeti'Ex'eption a* D

E
Q-11 /ompile and run GadHhreads5Ia-a: "#6%
public class BadThreads {
static String message;
private static class CorrectorThread extends Thread {
public void run() {
try {
sleep(1);
! catch ("nterrupted#xception e) {!
$$%ey statement 1:
message & '(ares do eat oats)';
!
!
public static void main(String args*+) thro,s
"nterrupted#xception {
(ne, CorrectorThread()))start();
message & '(ares do not eat oats)';
Thread)sleep(-);
$$%ey statement -:
System)out)println(message);
!
!
Hhe appli'ation should print out J+ares do eat oats5J Is it uaranteed to always do
this! If not: why not! 7ould it help to 'hane the parameters of the two in-o'ations
of Sleep! 3es'ri0e two ways to 'hane the proram to enfor'e su'h a uarantee5

You might also like