java lab comilla university
Department of Information & Communication Technology
LAB MANUAL
JAVA LAB
COMILLA UNIVERSITY
Dulal Chakraborty
Assistant Professor
Department of Information and Communication Technology
Comilla University.
List of Lab Exercises
Week 1 Name of the program
1 Write a Java program to find simple Interest.
2 Write a Java program to find all arithmetic operation
3 Write a Java program to convert any number to character number format from 0 to 9(Ex:i/p:1,o/p:one)
Week-2
4 Write a Java program to find the factorial of a given number
5 Write a Java program to find first number is multiple of second
6 Write a Java program to print number in sorting order
Week-3
7 Write a Java program to print the given number is Armstrong or not
8 Write a Program to find the Roots of a Quadratic Equation for the given values
9 Write a Program To print the Fibonacci series up to given numbers
Week -4
10 Write a Program To print the Prime Numbers upto given numbers
11 Write a Program To check whether the given string is Palindrome or not.
12 Write a Program To sort the given list of names
Week-5
13 Write a Program To find the product of matrices
14 Write a Program To find the sum of integers and then displays each integer, and sum of all the integers
Week-6
15 Write a Program That reads on a file and display the information that whether the file exists or not, to display the information about the file and find the type of file whether readable, writable and the length of bytes.
16 Write a Program That reads a file and displays the file on the screen within line number before each line
Week-7
17 Write a Program That prints a number of characters ,words,lines in that file
18 Write a Program That
implements a stack ADT
Implements infix expression into postfix expression
Week-8
19 Write an applet that displays a simple message
20 Write an applet That computes the payment of a loan based on the amount of the loan the interest rate and the no. of months. It takes one parameter from the browser: monthly rate if true, they interest rate is per month otherwise the interest rate is per annual.
Week-9
21 Write a Program That works as a simple calculator using Grid layout to arrange buttons for the digits and +,-,* % operations. Add a text filed to print the result.
22 Write an applet To handling the mouse events
Week-10
23 Write an applet To create multiple threads that correctly implements producer consumer problem using the concept of Inter thread communication
24 Write a Program That lets the user to create pie charts ,design your own interface
25 Write a Program That allow user to draw the line, rectangle and ou. als
Week-11
26 Write a Program That implements the client/server application. The client sends the data to the server, the client receives the data, uses it to produce a result and then sends the result back to the client. The client displays the result on the console.
Ex: The data sent by the client is radius of a circle and the result produced by the server is area of a circle
OBJECT ORIENTED PROGRAMMING:
OOP Concepts:
The object oriented paradigm is built on the foundation laid by the structured programming concepts. The fundamental change in OOP is that a program is designed around the data being operated upon rather upon the operations themselves. Data and its functions are encapsulated into a single entity.OOP facilitates creating reusable code that can eventually save a lot of work. A feature called polymorphism permits to create multiple definitions for operators and functions. Another feature called inheritance permits to derive new classes from old ones. OOP introduces many new ideas and involves a different approach to programming than the procedural programming.
Benefits of object oriented programming:
Data security is enfor
java lab comilla university
Department of Information & Communication Technology
LAB MANUAL
JAVA LAB
COMILLA UNIVERSITY
Dulal Chakraborty
Assistant Professor
Department of Information and Communication Technology
Comilla University.
List of Lab Exercises
Week 1 Name of the program
1 Write a Java program to find simple Interest.
2 Write a Java program to find all arithmetic operation
3 Write a Java program to convert any number to character number format from 0 to 9(Ex:i/p:1,o/p:one)
Week-2
4 Write a Java program to find the factorial of a given number
5 Write a Java program to find first number is multiple of second
6 Write a Java program to print number in sorting order
Week-3
7 Write a Java program to print the given number is Armstrong or not
8 Write a Program to find the Roots of a Quadratic Equation for the given values
9 Write a Program To print the Fibonacci series up to given numbers
Week -4
10 Write a Program To print the Prime Numbers upto given numbers
11 Write a Program To check whether the given string is Palindrome or not.
12 Write a Program To sort the given list of names
Week-5
13 Write a Program To find the product of matrices
14 Write a Program To find the sum of integers and then displays each integer, and sum of all the integers
Week-6
15 Write a Program That reads on a file and display the information that whether the file exists or not, to display the information about the file and find the type of file whether readable, writable and the length of bytes.
16 Write a Program That reads a file and displays the file on the screen within line number before each line
Week-7
17 Write a Program That prints a number of characters ,words,lines in that file
18 Write a Program That
implements a stack ADT
Implements infix expression into postfix expression
Week-8
19 Write an applet that displays a simple message
20 Write an applet That computes the payment of a loan based on the amount of the loan the interest rate and the no. of months. It takes one parameter from the browser: monthly rate if true, they interest rate is per month otherwise the interest rate is per annual.
Week-9
21 Write a Program That works as a simple calculator using Grid layout to arrange buttons for the digits and +,-,* % operations. Add a text filed to print the result.
22 Write an applet To handling the mouse events
Week-10
23 Write an applet To create multiple threads that correctly implements producer consumer problem using the concept of Inter thread communication
24 Write a Program That lets the user to create pie charts ,design your own interface
25 Write a Program That allow user to draw the line, rectangle and ou. als
Week-11
26 Write a Program That implements the client/server application. The client sends the data to the server, the client receives the data, uses it to produce a result and then sends the result back to the client. The client displays the result on the console.
Ex: The data sent by the client is radius of a circle and the result produced by the server is area of a circle
OBJECT ORIENTED PROGRAMMING:
OOP Concepts:
The object oriented paradigm is built on the foundation laid by the structured programming concepts. The fundamental change in OOP is that a program is designed around the data being operated upon rather upon the operations themselves. Data and its functions are encapsulated into a single entity.OOP facilitates creating reusable code that can eventually save a lot of work. A feature called polymorphism permits to create multiple definitions for operators and functions. Another feature called inheritance permits to derive new classes from old ones. OOP introduces many new ideas and involves a different approach to programming than the procedural programming.
Benefits of object oriented programming:
Data security is enfor
java lab comilla university
Department of Information & Communication Technology
LAB MANUAL
JAVA LAB
COMILLA UNIVERSITY
Dulal Chakraborty
Assistant Professor
Department of Information and Communication Technology
Comilla University.
List of Lab Exercises
Week 1 Name of the program
1 Write a Java program to find simple Interest.
2 Write a Java program to find all arithmetic operation
3 Write a Java program to convert any number to character number format from 0 to 9(Ex:i/p:1,o/p:one)
Week-2
4 Write a Java program to find the factorial of a given number
5 Write a Java program to find first number is multiple of second
6 Write a Java program to print number in sorting order
Week-3
7 Write a Java program to print the given number is Armstrong or not
8 Write a Program to find the Roots of a Quadratic Equation for the given values
9 Write a Program To print the Fibonacci series up to given numbers
Week -4
10 Write a Program To print the Prime Numbers upto given numbers
11 Write a Program To check whether the given string is Palindrome or not.
12 Write a Program To sort the given list of names
Week-5
13 Write a Program To find the product of matrices
14 Write a Program To find the sum of integers and then displays each integer, and sum of all the integers
Week-6
15 Write a Program That reads on a file and display the information that whether the file exists or not, to display the information about the file and find the type of file whether readable, writable and the length of bytes.
16 Write a Program That reads a file and displays the file on the screen within line number before each line
Week-7
17 Write a Program That prints a number of characters ,words,lines in that file
18 Write a Program That
implements a stack ADT
Implements infix expression into postfix expression
Week-8
19 Write an applet that displays a simple message
20 Write an applet That computes the payment of a loan based on the amount of the loan the interest rate and the no. of months. It takes one parameter from the browser: monthly rate if true, they interest rate is per month otherwise the interest rate is per annual.
Week-9
21 Write a Program That works as a simple calculator using Grid layout to arrange buttons for the digits and +,-,* % operations. Add a text filed to print the result.
22 Write an applet To handling the mouse events
Week-10
23 Write an applet To create multiple threads that correctly implements producer consumer problem using the concept of Inter thread communication
24 Write a Program That lets the user to create pie charts ,design your own interface
25 Write a Program That allow user to draw the line, rectangle and ou. als
Week-11
26 Write a Program That implements the client/server application. The client sends the data to the server, the client receives the data, uses it to produce a result and then sends the result back to the client. The client displays the result on the console.
Ex: The data sent by the client is radius of a circle and the result produced by the server is area of a circle
OBJECT ORIENTED PROGRAMMING:
OOP Concepts:
The object oriented paradigm is built on the foundation laid by the structured programming concepts. The fundamental change in OOP is that a program is designed around the data being operated upon rather upon the operations themselves. Data and its functions are encapsulated into a single entity.OOP facilitates creating reusable code that can eventually save a lot of work. A feature called polymorphism permits to create multiple definitions for operators and functions. Another feature called inheritance permits to derive new classes from old ones. OOP introduces many new ideas and involves a different approach to programming than the procedural programming.
Benefits of object oriented programming:
Data security is enfor
java lab comilla university
Department of Information & Communication Technology
LAB MANUAL
JAVA LAB
COMILLA UNIVERSITY
Dulal Chakraborty
Assistant Professor
Department of Information and Communication Technology
Comilla University.
List of Lab Exercises
Week 1 Name of the program
1 Write a Java program to find simple Interest.
2 Write a Java program to find all arithmetic operation
3 Write a Java program to convert any number to character number format from 0 to 9(Ex:i/p:1,o/p:one)
Week-2
4 Write a Java program to find the factorial of a given number
5 Write a Java program to find first number is multiple of second
6 Write a Java program to print number in sorting order
Week-3
7 Write a Java program to print the given number is Armstrong or not
8 Write a Program to find the Roots of a Quadratic Equation for the given values
9 Write a Program To print the Fibonacci series up to given numbers
Week -4
10 Write a Program To print the Prime Numbers upto given numbers
11 Write a Program To check whether the given string is Palindrome or not.
12 Write a Program To sort the given list of names
Week-5
13 Write a Program To find the product of matrices
14 Write a Program To find the sum of integers and then displays each integer, and sum of all the integers
Week-6
15 Write a Program That reads on a file and display the information that whether the file exists or not, to display the information about the file and find the type of file whether readable, writable and the length of bytes.
16 Write a Program That reads a file and displays the file on the screen within line number before each line
Week-7
17 Write a Program That prints a number of characters ,words,lines in that file
18 Write a Program That
implements a stack ADT
Implements infix expression into postfix expression
Week-8
19 Write an applet that displays a simple message
20 Write an applet That computes the payment of a loan based on the amount of the loan the interest rate and the no. of months. It takes one parameter from the browser: monthly rate if true, they interest rate is per month otherwise the interest rate is per annual.
Week-9
21 Write a Program That works as a simple calculator using Grid layout to arrange buttons for the digits and +,-,* % operations. Add a text filed to print the result.
22 Write an applet To handling the mouse events
Week-10
23 Write an applet To create multiple threads that correctly implements producer consumer problem using the concept of Inter thread communication
24 Write a Program That lets the user to create pie charts ,design your own interface
25 Write a Program That allow user to draw the line, rectangle and ou. als
Week-11
26 Write a Program That implements the client/server application. The client sends the data to the server, the client receives the data, uses it to produce a result and then sends the result back to the client. The client displays the result on the console.
Ex: The data sent by the client is radius of a circle and the result produced by the server is area of a circle
OBJECT ORIENTED PROGRAMMING:
OOP Concepts:
The object oriented paradigm is built on the foundation laid by the structured programming concepts. The fundamental change in OOP is that a program is designed around the data being operated upon rather upon the operations themselves. Data and its functions are encapsulated into a single entity.OOP facilitates creating reusable code that can eventually save a lot of work. A feature called polymorphism permits to create multiple definitions for operators and functions. Another feature called inheritance permits to derive new classes from old ones. OOP introduces many new ideas and involves a different approach to programming than the procedural programming.
Benefits of object oriented programming:
Data security is enfor
Department of Information and Communication Technology
Department of Information & Communication Technology
LAB MANUAL JAVA LAB COMILLA UNIVERIT! Dulal Chakraborty Assistant Professor Department of Information and Communication Technology Comilla University.
OO"L # $AVA LA% Department of Information and Communication Technology List of Lab Exercises Week 1 Name of the program # &rite a $a'a program to find (imple Intere(t) * &rite a $a'a program to find all arithmetic operation + &rite a $a'a program to con'ert any num,er to character num,er format from - to ./E01i2p1#3o2p1one4 Week-2 5 &rite a $a'a program to find the factorial of a gi'en num,er 6 &rite a $a'a program to find fir(t num,er i( multiple of (econd 7 &rite a $a'a program to print num,er in (orting order Week-3 8 &rite a $a'a program to print the gi'en num,er i( Arm(trong or not 9 &rite a "rogram to find the Root( of a :uadratic E;uation for the gi'en 'alue( . &rite a "rogram To print the <i,onacci (erie( up to gi'en num,er( Week -4 #- &rite a "rogram To print the "rime Num,er( upto gi'en num,er( ## &rite a "rogram To chec= >hether the gi'en (tring i( "alindrome or not) #* &rite a "rogram To (ort the gi'en li(t of name( Week-5 #+ &rite a "rogram To find the product of matrice( #5 &rite a "rogram To find the (um of integer( and then di(play( each integer3 and (um of all the integer( Week-6 #6 &rite a "rogram That read( on a file and di(play the information that >hether the file e0i(t( or not3 to di(play the information a,out the file and find the type of file >hether reada,le3 >rita,le and the length of ,yte() #7 &rite a "rogram That read( a file and di(play( the file on the (creen >ithin line num,er ,efore each line Week-7 #8 &rite a "rogram That print( a num,er of character( 3>ord(3line( in that file #9 &rite a "rogram That OO"L * $AVA LA% Department of Information and Communication Technology implement( a (tac= ADT Implement( infi0 e0pre((ion into po(tfi0 e0pre((ion Week-8 #. &rite an applet that di(play( a (imple me((age *- &rite an applet That compute( the payment of a loan ,a(ed on the amount of the loan the intere(t rate and the no) of month() It ta=e( one parameter from the ,ro>(er1 monthly rate if true3 they intere(t rate i( per month other>i(e the intere(t rate i( per annual) Week-9 *# &rite a "rogram That >or=( a( a (imple calculator u(ing ?rid layout to arrange ,utton( for the digit( and @3A3B C operation() Add a te0t filed to print the re(ult) ** &rite an applet To handling the mou(e e'ent( Week-10 *+ &rite an applet To create multiple thread( that correctly implement( producer con(umer pro,lem u(ing the concept of Inter thread communication *5 &rite a "rogram That let( the u(er to create pie chart( 3de(ign your o>n interface *6 &rite a "rogram That allo> u(er to dra> the line3 rectangle and ou) al( Week-11 *7 &rite a "rogram That implement( the client2(er'er application) The client (end( the data to the (er'er3 the client recei'e( the data3 u(e( it to produce a re(ult and then (end( the re(ult ,ac= to the client) The client di(play( the re(ult on the con(ole) E01 The data (ent ,y the client i( radiu( of a circle and the re(ult produced ,y the (er'er i( area of a circle OBJECT ORIENTED PROGRAMMING: OO"L + $AVA LA% Department of Information and Communication Technology OOP Concepts: The o,Dect oriented paradigm i( ,uilt on the foundation laid ,y the (tructured programming concept() The fundamental change in OO" i( that a program i( de(igned around the data ,eing operated upon rather upon the operation( them(el'e() Data and it( function( are encap(ulated into a (ingle entity)OO" facilitate( creating reu(a,le code that can e'entually (a'e a lot of >or=) A feature called polymorphi(m permit( to create multiple definition( for operator( and function() Another feature called inheritance permit( to deri'e ne> cla((e( from old one() OO" introduce( many ne> idea( and in'ol'e( a different approach to programming than the procedural programming) Benefits of object oriented programming: Data (ecurity i( enforced) Inheritance (a'e( time) U(er defined data type( can ,e ea(ily con(tructed) Inheritance empha(iEe( in'ention( of ne> data type() Large comple0ity in the (oft>are de'elopment cn ,e ea(ily managed) Basic C++ Knowledge: C@@ ,egan it( life in %ell La,(3 >here %Darne trou(trup de'eloped the language in the early #.9-() C@@ i( a po>erful and fle0i,le programming language) Thu(3 >ith minor e0ception(3 C@@ i( a (uper(et of the C "rogramming language) The principal enhancement ,eing the o,Dect Foriented concept of a cla(() A Cla(( i( a u(er defined type that encap(ulate( many important mechani(m() Cla((e( ena,le programmer( to ,rea= an application up into (mall3 managea,le piece(3 or o,Dect() Basic concepts of Object oriented programming:
Object: O,Dect( are the ,a(ic run time entitie( in an o,DectAoriented (y(tem) thy may repre(ent a per(on3 a place3 a ,an= account3 a ta,le of data or any item that the program ha( to handle) Class: The entire (et of data and code of an o,Dect can ,e made of a u(er defined data type >ith the help of a cla(() I fact3 O,Dect( are 'aria,le( of the type cla(() Once a cla(( ha( ,een defined3 >e can create any num,er of o,Dect( ,elonging to that cla(( A cla(( i( thu( a collection of o,Dect( of (imilar type) for e0ample1 mango3 apple3 and orange are mem,er( of the cla(( fruit) e01 fruit mangoG >ill create an o,Dect mango ,elonging to the cla(( fruit) Data Abstraction and Encapsulation: OO"L 5 $AVA LA% Department of Information and Communication Technology The >rapping up of data and function( in to a (ingle unit i( =no>n a( encap(ulation) Data encap(ulation i( the mo(t (tri=ing feature of a cla(() The data i( not acce((i,le to the out(ide >orld3 and only tho(e function( >hich are >rapped in the cla(( can acce(() Thi( in(ulation of the data from direct acce(( ,y the program i( called data hiding)
Abstraction : A,(traction refere( to the act of repre(enting e((ential feature( >ithout including the ,ac=ground detail( or e0planation() (ince the cla((e( u(e the concept of data a,(traction 3thy are =no>n a( a,(traction data type/ADT4)
Inheritance : Inheritance i( the proce(( ,y >hich o,Dect( of one cla(( ac;uire the propertie( of o,Dect( of another cla(() Inheritance (upport( the concept of hierarchical cla((ification) for e0ample1 The ,ird Hro,in H i( a part of the cla(( Hflying ,irdH >hich i( agian a part of the cla(( H,irdH) The concept of inheritance pro'ide the idea of reu(a,ility) POLYMORPHISM: OO"L 6 $AVA LA% %ird Attri,ute(1 <eather( Lay egg( <lying ,ird Attri,ute(1 AAAAAAAAAAA AAAAAAAAAA Non flying ,ird Attri,ute(1 AAAAAAAAAAA AAAAAAAAAAA Ro,in Attri,ute(1 IIIIIIIII >allo> Attri,ute(1 IIIIIIIII "enguin Attri,ute(1 IIIIIIIII Ji>i Attri,ute(1 IIIIIIIII Department of Information and Communication Technology "olymorphi(m i( another important oop concept) "olymorphi(m mean( the a,ility to ta=e more than one form) an operation may e0hi,it different in(tance() The ,eha'ior depend( upon the type( of data u(ed in the operation) The proce(( of ma=ing an operator to e0hi,it different ,eha'ior( in different in(tance i( =no>n a( operator o'erloading) "olymorphi(m play( an important role in allo>ing o,Dect( ha'ing different internal (tructure( to (hare the (ame e0ternal interface) "olymorphi(m i( e0ten(i'ely u(ed if implementing inheritance) The Object-Oriented Approach The fundamental idea ,ehind o,DectAoriented language( i( to com,ine into a (ingle program entity ,oth data and the function( that operate on that data) uch an entity i( called an o,Dect) An o,DectH( function(3 called mem,er function( in C@@ /,ecau(e they ,elong to a particular cla(( of o,Dect(43 typically pro'ide the only >ay to acce(( it( data) If you >ant to read a data item in an o,Dect3 you call a mem,er function in the o,Dect) It >ill read the item and return the 'alue to you) !ou canHt acce(( the data directly) The data i( hidden3 (o it i( (afe from accidental alteration) Data and it( function( are (aid to ,e encap(ulated into a (ingle entity) Encap(ulation and data hiding are =ey term( in the de(cription of o,DectAoriented language() OO"L 7 $AVA LA% hape Dra>/4 Circle O,Dect Dra>/4 %o0 O,Dect Dra>/4 Triangle O,Dect Dra>/4 Department of Information and Communication Technology 1ava History: $a'a i( a generalApurpo(eG o,Dect oriented programming language de'eloped ,y un Micro(y(tem( of UA in #..#) Originally called Koa=L ,y $ame( ?o(ling3 one of the in'entor( if the language) Thi( goal had a (trong impact on the de'elopment team to ma=e the language (imple3 porta,le3 highly relia,le and po>erful language) $a'a al(o add( (ome ne> feature() &hile C@@ i( a (uper(et of C) $a'a i( neither a (uper(et nor a (u,(et of C or C@@) OO"L 8 $AVA LA% C++ C Java Department of Information and Communication Technology Process of building and running java application programs: The >ay the(e tool( are applied to ,uild and run application program( i( create a program) &e need create a (ource code file u(ing a te0t editor) The (ource code i( then compiled u(ing the Da'a compiler Da'ac and e0ecuted u(ing the Da'a interpreter Da'a) The Da'a de,ugger Dd, i( u(ed to find error() A complied Da'a program can ,e con'erted into a (ource code) OO"L 9 $AVA LA% Te0t Editor $a'a ource Code $a'adoc MTML file( $a'ac $a'a Cla(( <ile $a'ah Meader <ile( $a'a /only file name4 $d, /data,a(e4 $a'a progra m Output Department of Information and Communication Technology AIM: Name of the Experiment: #) &rite a Da'a program to find the (imple intere(t) HW/SW requirements: "roce((or 1 AMD Athelon N #)78 ?ME RAM 1 *67 M% Mard Di(= 1 5- ?% $DJ i( re;uired3 &ith compiler() Algorithm: #) tart the program) *) Declare the 'aria,le( and a((ume 'alue( +) Intere(tTopayOprincipleBtimeBrate2#--G 5) print the 'alue() 6) End of cla(( and main method) 7) (top the proce(( Test Data: a4 Valid data (et(1 *6--- int 'alue a( principal3 #*)6f float 'alue a( rate3 *)86 a( dou,le a( intere(tTo"ay ,4 Limiting 'alue (et(1 Only integer 'alue( can ,e (tored in the 'ar) principal) c4 In'alid data (et(1 If >e a((ign float 'alue in 'ar) principal error >ill occur) Results for different data sets: "rincipalamount i( R()*6--- intere(tOR()96.+)86 Total amount to pay to clear the loan O R()++6.+)86 Viva-Voc Questions : 1) What is a method? And What is OOPS? 2) What is the signature of a method? 3) What is the difference between an instance variable and a class variable? 4) What is an abstract method? 5) What is an abstract class? 6)What is an object reference
OO"L . $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *) &rite a Da'a program to find the gi'en num,er( of arithmetic operation() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: tep#1(tart tep*1input n3r3( tep+1(O- tep51dOnC#- tep61(O(@d tep71nOn2#- tep81 i( nQO- tep91 repeat (tep 5 to (tep 7 till (tep 8 i( true tep.1>hen (tep 8 fall( tep#-1print ( tep##1(top Test Data: Valid Data Set: 23415 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the num,er >ho(e digit( are to ,e added1#*+5 um of the digit(1#- Enter the num,er >ho(e digit( are to ,e added1+5678 um of the digit(1A*8 Enter <ir(t Num,er1 #* Enter econd Num,er1 5 Addition of a and , O #7 u,traction of a and , O 9 OO"L #- $AVA LA% Department of Information and Communication Technology Multiplication of a and , O 59 Di'i(ion of a and , O + Viva Voce Questions 7) What is an exception? 8) Why does the compiler complain about Interrupted Exception when I try to use Thread's sleep method? 9) Why do methods have to declare the exceptions they can throw? 10) What's the difference between a runtime exception and a plain exception-why don't you runtime exceptions have to be declared? 11) What is an applet? 12) . How do applets differ from applications? OO"L ## $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: +) &rite a Da'a program to find the gi'en (ingle digit num,er u(ing (>itch ca(e) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: Algorithm: #) tart the program) *) Read a (tring >ith input(treamReader/y(tem)in4) +) con'ert the (tring into Integer)par(eInt/(tdin)readLine/44G 5) %y u(ing (>itch ca(e / multi >ay deci(ion (tatement4 >hen a match i( found3 that ca(e i( e0ecuted) 6) Default it i( a ,rea= (tatement e0it the (>itch (tatement) 7) (top the program) Test Data: Valid Data Set: 4 Invalid Data Set: -4 Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter Any po(iti'e (ingle digit num,er 1 5 <our Enter Any po(iti'e (ingle digit num,er1 6 <i'e OO"L #* $AVA LA% Department of Information and Communication Technology Viva Voce Questions 13) . Can I write 1ava code that works both as an applet and as a stand-alone application? 14). What is the difference between an application, an applet, and a servlet? 15) Several applet methods seem special, in that I need to define them even if my own code doesn't invoke them--what are the methods, and when (and by whom) are they invoked? 16). Should applets have constructors? 17) . How can my applet tell when a user leaves or returns to the web page containing my applet? 18) . How do I read number information from my applet's parameters, given that Applet's getParameter method returns a String? OO"L #+ $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: 5) &rite a Da'a program to find the gi'en factorial num,er() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: tep#1 (tart tep*1 input n3I3f tep+1 fOiO# tep51 if/iROn4 tep61 fOfBi tep71 iOi@# tep81 repeat from (tep6 to (tep7 till (tep( true tep91 print f tep.1 (top Test Data: Valid Data Set: 5 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the num,er 16 <actorial 1#*- Enter the num,er1+ <actorial17 Viva Voce Questions 19) . When I subclass Applet, why should I put setup code in the init() method? Why not just a constructor for my class? 20). Can I use an http URL to write to a file on the server from an applet? 21) . Can applets launch programs on the server? 22) . Can applets launch programs on the client? 23) . How do you do file I/O from an applet? 24) . How do I access remote machine's file system through 1ava Applet? OO"L #5 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: 6)&rite a Da'a program to chec= >hether the fir(t num,er i( a multiple of (econd num,er) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: # tart the program) * Read a (tring >ith input(treamReader/y(tem)in4) + con'ert the (tring into Integer)par(eInt/(tdin)readLine/44G 5 %y u(ing (>itch ca(e / multi >ay deci(ion (tatement4 >hen a match i( found3 that ca(e i( e0ecuted) 6 Default it i( a ,rea= (tatement e0it the (>itch (tatement) 7 (top the program) Test Data: Valid Data Set: 2 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the <ir(t num,er * Enter the (econd num,er1 5 The fir(t num,er i( not the multiple of (econd num,er Enter the <ir(t num,er #* Enter the (econd num,er + The fir(t num,er i( the multiple of (econd num,er OO"L #6 $AVA LA% Department of Information and Communication Technology Viva Voce Questions 25) What is a thread? 26) . How do I create a thread and start it running? 27) . How many threads can I create? 28) . How does Thread's stop method work--can I restart a stopped thread? 29) . If I create a thread, and then null out the reference to it, what happens to the thread? Does it get interrupted or what? 30) . How should I stop a thread so that I can start a new thread later in its place? OO"L #7 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: 7) &rite a Da'a program to chec= gi'en num,er( in a (orting order) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) *) Create a cla(( and 'aria,le( >ith data type() +) Read a (tring >ith Datainput(treamReader/y(tem)in4) 5) con'ert the (tring into Integer)par(eInt/(tdin)readLine/44G 6) %y u(ing for loop rotating the array) 7) "rint the concatenation of array() 8) top the program) Test Data: Valid Data Set: 6 9 3 2 0 1 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter #- Element( into Array * + 5 # 6 8 9 7 OO"L #8 $AVA LA% Department of Information and Communication Technology + # Re;uired Order i( # # * + 5 6 7 8 9 Viva Voce Questions 31) .How do I specify pause times in my program? 32) Why is thread synchronization important for multithreaded programs? 33) . What is a monitor? 34) . How does the synchronized keyword work? 35) . What objects do static synchronized methods use for locking? 36) . How do the wait and notifyAll/notify methods enable cooperation between threads? OO"L #9 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: 8) &rite a Da'a program to generate the Arm(trong num,er) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) *) Create a cla(( and 'aria,le( >ith data type() +) Declaration of the main cla(() 5) Read a (tring >ith Datainput(treamReader/y(tem)in4) 6) con'ert the (tring into Integer)par(eInt/(tdin)readLine/44G 7) (umO(um@rBrBr formula) 8) u(ing if el(e (tatement) 9) top the program) Test Data: Valid Data Set: 153 Invalid Data Set: 4 Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter any "o(iti'e Integer Num,er 1 5 ?i'en Num,er i( not Arm(trong Num,er Enter any "o(iti'e Integer Num,er 1 #6+ ?i'en Num,er i( Arm(trong Num,er OO"L #. $AVA LA% Department of Information and Communication Technology Viva Voce Questions 37) . How do I achieve the effect of condition variables if the 1ava platform provides me with only wait and notifyAll/notify methods? 38) . How do I make one thread wait for one or more other threads to finish? 39) . What do I use the yield method for? 40) . Does the 1ava Virtual Machine protect me against deadlocks? 41) . I have several worker threads. I want my main thread to wait for any of them to complete, and take action as soon as any of them completes. I don't know which will complete soonest, so I can't just call Thread.join on that one. How do I do it? 42) How do I do keyboard (interactive) I/O in 1ava? OO"L *- $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: 9)&rite a Da'a program to generate the ;uadratic e;uation) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) Import the pac=age() *) Create a cla(( and 'aria,le( >ith data type() +) Declaration of the main cla(() 5) Read a (tring >ith input(treamReader/y(tem)in4) 6) con'ert the (tring into Integer)par(eInt/(tdin)readLine/44G 7) %y u(ing if/dOO-4 KRoot( are E;ualentL loop rotating the integer 'alue) 8) if/dS-4 KRoot( are RealL other>i(e /TRoot( are ImaginaryT4G 9) Repeat( enter the 'alue until end of loop) .) End of cla(( and main method) #-) top the program) Test Data: Valid Data Set: 1 9 4 Invalid Data Set: 2 3 Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter 'alue of a1 OO"L *# $AVA LA% Department of Information and Communication Technology * Enter 'alue of ,1 + Enter 'alue of c1 5 Root( are Imaginary Enter 'alue of a1 # Enter 'alue of ,1 . Enter 'alue of c1 5 Root( are Real Root# O A-)57998##*696-8*65+ Root2 = -8.531128874149275 Viva Voce Questions 43) . Is there a way to read a char from the keyboard without having to type carriage- return? 44). How do I read a line of input at a time? 45) . How do I read input from the user (or send output) analogous to using standard input and standard output in C or C++? 46) . Is there a standard way to read in int, long, float, and double values from a string representation? 47) . How do I read a String/int/boolean/etc from the keyboard? 48) . I try to use "int i System.in.read();" to read in an int from the standard input stream. It doesn't work. Why? OO"L ** $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: .)&rite a Da'a program to generate the <i,onacci (erie(3 gi'en num,er of n 'alue() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM AL?ORITMM1 tep#1 (tart tep*1 read I303f3f#3f* tep+1 fO-3f#O#3f*O# tep51 do I@@ <#Of* <*Of <Of#@f* &hile /iROn4 tep61 print f Step6: stop Test Data: Valid Data Set: 12 Invalid Data Set: -12 Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the num,er u >ant in <i,onacci (erie(1#* - # # * + 6 9 #+ *# Enter the num,er u >ant in <i,onacci (erie(16 OO"L *+ $AVA LA% Department of Information and Communication Technology - # # * + Viva Voce Questions 49) . I use the following to read an int. It does not work. Why? 50). I'm trying to read in a character from a text file using the DataInputStream's readChar() method. However, when I print it out, I get?`s. 51) . Why do I get garbage results when I use DataInputStream's readInt or readFloat methods to read in a number from an input string? 52). How do I read data from a file? 53) . How do I write data to a file? 54). How do I append data to a file? OO"L *5 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #-) &rite a Da'a program to find the prime num,er( upto gi'en num,er) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: tep#1 (tart tep*1 read n 'alue tep+1 for iO# iROn tep51repeat a , c d e a4factorial e;ual to - ,4 for iO#3DRO# repeat c3d c4if i percentage D e;ual to Eero d4 fact e;ual to factorial added >ith one e4 if factorial e;ual to*print a( prime num,er (tep61 di(play the prime no till nth num 71 (top Test Data: Valid Data Set: 2 3 5 Invalid Data Set: 1 4 Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter "o(iti'e 'alue 1 #- * + 6 8 Enter "o(iti'e 'alue 1 * 7 * + 6 OO"L *6 $AVA LA% Department of Information and Communication Technology Viva Voce Questions 55). When do I need to flush an output stream? 56) . Why do I see no output when I run a simple process, such as r.exec("/usr/bin/ls")? 57) . Can I write objects to and read objects from a file or other stream? 58) . How do I format numbers like C's printf()? 59). How do I do file I/O in an applet? 60) . How do I do I/O to the serial port on my computer AIM: Name of the Experiment: ##)&rite Da'a program di(play the gi'en (tring i( palindrome or not Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) Import the pac=age() *) Read a (tring >ith input(treamReader/y(tem)in4) +) re'er(e the (tring and (tore into another (tring 5) if ,oth the (tring( are e;ual OO"L *7 $AVA LA% Department of Information and Communication Technology >rite palandrom el(e >rite not a palandrom 6) End of cla(( and main method) 7) (top the program) Test Data: Valid Data Set: amma Invalid Data Set: ananth Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter a (tring madam ?i'en (tring i( palindrome Enter a (tring c(e ?i'en (tring i( not palindrome OO"L *8 $AVA LA% Department of Information and Communication Technology Viva Voce Questions 61) . How do I do formatted I/O like printf and scanf in C/C++? 62). How do I read a file containing ASCII numbers? 63) . Why do I have trouble with System.out.println()? 64). How do I write to the serial port on my PC using 1ava? 65) . Is it possible to lock a file using 1ava ? 66) . How do I make the keyboard beep in 1ava? OO"L *9 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #*)&rite a Da'a program arrange (tring( into a((ending order Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) *) Create a cla(( and 'aria,le( >ith data type() +) Read a (tring >ith Datainput(treamReader/y(tem)in4) 5) con'ert n 'alue to integer 6) repeate U7V until I Rn 7) repeate U8V until D RnAi 8) if aWDXRaWD@#X then change 'alue from aWDX to aWD@#X 9) "rint the array .) top the program) OO"L *. $AVA LA% Department of Information and Communication Technology Test Data: Valid Data Set: deva ananth amma Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the (tring 1 deva ananth amma
a((ending order1 amma ananth deva Viva Voce Questions 67). How do I make I/O faster? My file copy program is slow. 68). How do I do formatted I/O of floating point numbers? 69). How do I read numbers in exponential format in 1ava? 70) . How do I delete a directory in 1ava? 71). How do I tell how much disk space is free in 1ava? 72) . How do I get a directory listing of the root directory C:\ on a PC? 73). I did a read from a Buffered stream, and I got fewer bytes than I specified OO"L +- $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment #+)&rite a Da'a program to find the product of the matrice( ,y u(ing t>o dimen(ional array() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: tep#1 (tart tep*1read I3D3=3aW+XW+X3,W+XW*X3cW+XW*X tep+1 read aW+XW+X Y ,W+XW*X tep 51iO-3DO-3=O- tep61 if iR+ then i@@ el(e goto # tep71 if DR+ then D@@ el(e goto 6 tep81 if =R+ then =@@ el(e goto 7 tep91 cWiXWDXOcWiXWDX@aW=XWDXB,WiXW=X tep.1 print aWiXWDX3,WiXWDX3cWiXWDX tep #-1 (top Test Data: Valid Data Set: 1 2 3 4 5 6 7 8 9 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the element( of #(t matri0 # * + 5 6 7 8 9 OO"L +# $AVA LA% Department of Information and Communication Technology . Enter the element( of the *nd matri0 # - - - # - - - # The productof the matrice( i( # * + 5 6 7 8 9 . Viva Voce Questions 74) . How do I redirect the System.err stream to a file? 75) . What are the values for the Unicode encoding schemes? 76) . How do I print from a 1ava program? 77) . What are the properties that can be used in a Print1ob? 78) . How do I get 1ava talking to a Microsoft Access database? 79). How do I do I/O redirection in 1ava using exec()? OO"L +* $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #6)&rite Da'a program di(play the file i( e0i(t( and num,er of ,yte( in the gi'en file Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program3 import the pac=age() *) create an o,Dect of UfiV u(ing fileinput(tream cla(( +) if chec= the file e0it then print Ufile i( e0itV el(e print Ufile doe( not e0it 5) "rint the num,er of ,yte( of gi'en file( i( u(ing fi)a'ail/4 function 6) top the program Test Data: Valid Data Set: C1ZDOCUME[#Z(tudentZDe(=topSDa'a p#6 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets OO"L ++ $AVA LA% Department of Information and Communication Technology C1ZDOCUME[#Z(tudentZDe(=topSDa'a p#6 num,er of ,yte( in thi( file i(1*5. viva voce Questions 80) What is the signature of a method? 81) How do I create an instance of a class? 82) . Why do I get the java.lang.UnsatisfiedLinkError when I run my 1ava program containing Native Method invocations? 83) Given a method that doesn't declare any exceptions, can I override that method in a subclass to throw an exception? 84) What's the difference between a runtime exception and a plain exception-why don't runtime exceptions have to be declared? 85) Why do methods have to declare the exceptions they can throw? 86) Why does the compiler complain about Interrupted Exception when I try to use Thread's sleep method? OO"L +5 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #7)&rite Da'a program di(play the line no ,efore the content of the gi'en file Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program3 import the pac=age() *) create an o,Dect of UfiV u(ing fileinput(tream cla(( +) compute countO- 5) repeate U5V until file i( empty 6) if the ne> line i( arri'ed then printf counter3count@@ 7)top the program Test Data: Valid Data Set: line no1#import Da'a)util)BG line no1*cla(( p#5 line no1+\ line no15pu,lic (tatic 'oid main/tring arg(WX4 line no16\ Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets OO"L +6 $AVA LA% Department of Information and Communication Technology line no1#import Da'a)util)BG line no1*cla(( p#5 line no1+\ line no15pu,lic (tatic 'oid main/tring arg(WX4 line no16\ line no17int (O-G line no18tringTo=eniEer to=enOne> tringTo=eniEer/arg(W-X3T3T4G line no19>hile/to=en)ha(MoreTo=en(/44 line no1.(O(@Integer)par(eInt/to=en)ne0tTo=en/44G line no1#-y(tem)out)println/(4G line no1##] line no1#*] line no1#+ line no1#5^ Viva voce Questions 87) What is an exception? 88) I can't seem to change the value of an Integer object once created. 89) How can I safely store particular types in general containers? 90) Why is the String class final? I often want to override it. 91) . How do static methods interact with inheritance? 92) Where can I find examples of the use of the 1ava class libraries? OO"L +7 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #8)&rite Da'a program di(play the nof line(3>ord( and character( of a gi'en file Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #4 tart the program3 import the pac=age() *4 create an o,Dect of UfiV u(ing fileinput(tream cla(( +4 compute countO-3>ordO-3lineO#3(paceO- 54 repeate U5V until file i( empty 64 if fi)read/4 e;ual to ne> line then line@@ el(e fi)read/4 e;ual to (pace then >ord@@ el(e char@@ 74 print >ord3line3char 84 top the program OO"L +8 $AVA LA% Department of Information and Communication Technology 94 tart the program3 import the pac=age() .4 create an o,Dect of UfiV u(ing fileinput(tream cla(( #-4 compute countO-3>ordO-3lineO#3(paceO- ##4 repeate U5V until file i( empty #*4 if fi)read/4 e;ual to ne> line then line@@ el(e fi)read/4 e;ual to (pace then >ord@@ el(e char@@ #+4 print >ord3line3char #54 top the program Test Data: Valid Data Set: C1ZDOCUME[#Z(tudentZDe(=topSDa'a p#-
Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets C1ZDOCUME[#Z(tudentZDe(=topSDa'a p#8 nof charecter(1**8 >ord(1*+ line(#5of the gi'en file Viva voce Questions 93) How can I find the format of a .class file/any file? 94) What are "class literals"? 95) What is an object reference? 96) What does it mean that a method or class is abstract? 97) What is an abstract class? 98) What is an abstract method? OO"L +9 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #9)&rite a Da'a program to implement (tac= Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: 1) a)Algorithm For Inserting an Item into the Stack s: "rocudure "UM/3I_E3TO"3ITEM4 Array I_E tac= (iEe TO" tac= "ointer ITEM 'alue in a cell tep#1\Chec= for (tac= o'erflo>] If TO"SOI_E then "rintf/Utac= o'erflo>V4 Return tep*1\Increment pointer top] TO"OTO"@# tep +1\In(ert ITEM at top of the tac=] WTO"XOITEM Return b)Algorithm For Deleting an Item into the Stack function "O"/3TO"4 Array TO" tac= "ointer tep#1\Chec= for (tac= underflo>] If TO"O- then "rintf/Utac= underflo>V4 Return tep*1\Return former top element of (tac=] ITEMO/WTO"X4G +1\Decrement pointer TO"] TO"OTO"A# Return c)Algorithm For display Items into a Stack S function "O"/3TO"4 Array TO" tac= "ointer OO"L +. $AVA LA% Department of Information and Communication Technology tep#1\Chec= for (tac= underflo>] If TO"O- then "rintf/U(tac= i( emptyV4 Return tep*1\di(play (tac= element( until TO" 'alue] "rint/WTO"X4 TO"OTO"@# d)Algorithm For display top item from the Stack S function "O"/3TO"4 Array TO" tac= "ointer tep#1\Chec= for (tac= underflo>] If TO"O- then "rintf/U(tac= i( emptyV4 Return tep*1\di(play TO" 'alue into the tac=] "rint/WTO"X4 Test Data: Valid Data Set: enter your choice #)pu(h/43*)pop/43+)di(play/4 * enter any item #+ enter any operation/y2n4 y enter your choice #)pu(h/43*)pop/43+)di(play/4 # or Enter the Infi0 E0pre((ion```)1 a@,Bc The "o(tfi0 E0pre((ion i(```````)a,cB@ Invalid Data Set: 5 Limiting Data Sets: Integer Range (A+*879 to +*8784 OO"L 5- $AVA LA% Department of Information and Communication Technology Results for different Data Sets enter your choice #)pu(h/43*)pop/43+)di(play/4 # enter any item #* enter any operation/y2n4 y enter your choice #)pu(h/43*)pop/43+)di(play/4 # enter any item +5 enter any operation/y2n4 y enter your choice #)pu(h/43*)pop/43+)di(play/4 + +5 #* enter any operation/y2n4 n OR Enter the Infi0 E0pre((ion```)1 a@,Bc The "o(tfi0 E0pre((ion i(```````)a,cB@ Viva voce Questions 99) How do I create an instance of a class? 100) What is an object reference? 101) What are "class literals"? 102) What are the values for the Unicode encoding schemes? 103) How do I print from a 1ava program? 104) How do I get a directory listing of the root directory C:\ on a PC? OO"L 5# $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: #.)&rite a Da'a applet to di(play (imple me((age Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #1(tart *1 ta=e applet( * 1di(play + End applet Test Data: Valid Data Set: 300 400 500 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets OO"L 5* $AVA LA% Department of Information and Communication Technology Viva voce Questions 105) How do I delete a directory in 1ava? 106) How do I read numbers in exponential format in 1ava? 107) How do I do formatted I/O of floating point numbers? 108) How do I make I/O faster? My file copy program is slow. 109) Is it possible to lock a file using 1ava ? 110) How do I write to the serial port on my PC using 1ava? ) OO"L 5+ $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *-)&rite an applet that compute( the payment of a loan on the amount of the loan3the intere(t rate and the num,er of month()it ta=e( one parameter from the ,ro>(er1monthly rate3if true3the intere(t rate i( per month other>i(e the intere(t rate i( per annual) Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: # (tart * ta=e applet + add/ne> La,el/T(elect month(2year( T44G 5 action"erformed/ActionE'ent e4 6 el(e 7 (top Integer)par(eInt/ta)getTe0t/44BInteger)par(eInt/tm#)getTe0t/44BInteger)par(eInt/tr)getTe0t/442#*-- Test Data: Valid Data Set: 24 months Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets OO"L 55 $AVA LA% Department of Information and Communication Technology Viva voce Questions 111) Why do I have trouble with System.out.println()? 112) How do I read a file containing ASCII numbers? 113) How do I do formatted I/O like printf and scanf in C/C++? 114) How do I do I/O to the serial port on my computer? 15) How do I do file I/O in an applet? 116) Can I write objects to and read objects from a file or other stream? OO"L 56 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *#)>rite a Da'a program that >or=( a( a (imple calculator Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: # (tart * ta=e applet + add/ne> La,el(4 5 action"erformed/ActionE'ent e4 6 el(e 7 prniln iOInteger)par(eInt/(*42Integer)par(eInt/(#4G 8 (top tf)(etTe0t/tring)'alueOf/i44G Test Data: Valid Data Set: press any no: 2 3 4 7 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets OO"L 57 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: **)&rite a Da'a program to implement the A""LET "ACJA?E3 dra> Mou(e e'ent handler program() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) *) Import the pac=age( of applet3 a>t3 a>t)e'ent) +) Create a cla((e(3 method() 5) Mou(e moment(3 mou(e Clic=ed3 mou(e "re((ed3 mou(e Relea(ed3 mou(e Entered3 mou(e E0ited3 mou(e Dragged e'ent( arg() 6) g)dra>tring/4 application of ?raphical U(er Interface) 7) >hile rotating mou(e e'ent arg() 8) The mou(e e'ent argument( e0ecution) 9) "rinting in the (eparated Applet 'ie>er >indo>) .) top the program) OO"L 58 $AVA LA% Department of Information and Communication Technology Test Data: Valid Data Set: click mouse Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Viva voce Questions 117) Why do I see no output when I run a simple process, such as r.exec("/usr/bin/ls")? 118) When do I need to flush an output stream? 119) How do I append data to a file? 120) How do I write data to a file? 121) How do I read data from a file? 122) Explain the Polymorphism principle. OO"L 59 $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *+)>rite a Da'a program on interthread communication Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: 1 tart * ta=e cla(( + for (ingal >ait 5 true -r fal(e 6 println ne> InterThread/Do,4 7 (top Test Data: Valid Data Set: 0 1 2 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets put1 - got1 - put1 # got1 # put1 * got1 * put1 + got1 + put1 5 got1 5 OO"L 5. $AVA LA% Department of Information and Communication Technology Viva voce Questions 123) Why do methods have to declare the exceptions they can throw? 124) Explain the different forms of Polymorphism. 125) Describe the principles of OOPS 126) What is the difference between encapsulation and datahiding.explain with example 127) What is the use/advantage of function overloading 128) Explain the Inheritance Principle OO"L 6- $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *6)&rite a Da'a program to implement the A""LET "ACJA?E3 dra> Line(3 Rectangle(3 Rounded Rectangle(3 filled "olygon( program() Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: #) tart the program) *) Import the pac=age( of applet3a>t3a>t)e'ent) +) Create a cla((e(1 pu,lic 'oid paint/?raphic( g4) 5) A((ume the 'alue( of (tring3 color and font) 6) g)dra>tring/4 application of ?raphical U(er Interface) 7) "rinting in the (eparated Applet 'ie>er >indo>) 8) top the program) Test Data: Valid Data Set: 200 400 500 Invalid Data Set: 1000000000 Limiting Data Sets: Integer Range (A+*879 to +*8784 OO"L 6# $AVA LA% Department of Information and Communication Technology Results for different Data Sets Viva voce Questions 129) Can we inherit private members of class ? 130) Why do you need abstraction? 131) How macro execution is faster than function ? 132) What is size of class having no variable & 1 function which returns int 133) Difference between object-oriented programming and procedure oriented programming 134) What do you mean by realization in oops, what is presistent,transient object. OO"L 6* $AVA LA% Department of Information and Communication Technology AIM: Name of the Experiment: *7)&rite a Da'a program that implement( the client2(er'er program Software/Hardware Requirements: S/W: $DJ#)6/$AVA43 Office P"3 &indo>( NT er'er >ith er'ice "ac= H/W: "entium IV3 Intel Mother %oard "roce((or3 5- ?% MDD3 *67 M% RAM ALGORITHM: # tart the program) * Import the pac=age( of applet3 a>t3 a>t)e'ent) + Create a cla((e(3 method() 5 ta=e er'eroc=et ((ocOne> er'eroc=et 6 defalt thro>( E0ception 7 di(play ,yteWX dataOm(g)get%yte(/4G 8 println iO+)#5B<loat)par(e<loat/(tr4B<loat)par(e<loat/(tr4G 7 (top program Test Data: Valid Data Set: hai enter socket no:127.0.0,21 Invalid Data Set: Not applicable Limiting Data Sets: Integer Range (A+*879 to +*8784 Results for different Data Sets Enter the >ord 1 hallo> ?i'en >ord i(1 hallo> enter socket no:127.0.0,21 system no :192.168.10.20 is connected Viva voce questions: 148) What is the use of procedure overriding 149) What are enumerators? and what are in-line functions? giv ans with eg. 150) Is it possible to change the address of an array? 151) What is the race condition? 152) What are the advantages of Object Oriented Modeling? 153) What is the memory allocation for pointer? OO"L 6+ $AVA LA% Department of Information and Communication Technology REFERENCES: BOOKS: 1. Thinking in 1ava - %ruce Ec=el 2. Beginning 1ava 2- I',or horton 3. 1ust 1ava 1.2- "eter 'an der linder WEBSITES: 1. www.java.com 2. www.java.sun.com 3. www.freewarejava.com 4. www.javalobby.org OO"L 65 $AVA LA%