Академический Документы
Профессиональный Документы
Культура Документы
No Topics
Hands-on Assignment Status
. Covered
Example1)
If the two command line arguments are Wipro and Bangalore then
the output generated should be Wipro Technologies Bangalore.
Command
1 Line
Argument
Example2)
If the command line arguments are ABC and Mumbai then the
output generated should be ABC Technologies Mumbai
Command
2 Example1) Line
Argument
C:\> java Sample John
O/P Expected : Welcome John
Command
3 Example1) Line
Argument
C:\>java Sample 10 20
O/P Expected : The sum of 10 and 20 is 30
Loops
No Topics
Hands-on Assignment Status
. Covered
5 If Statement
Initialize a character variable in a program and
print 'Alphabhet' if the initialized value is an alphabhet,
6 If the gender is 'Female' and age is between 59 and 100, the If Statement
percentage of interest is 9.2%.
7 If Statement
Initialize a character variable with an alphabhet in a
program.
Example1)
i/p:a
o/p:a->A
The program should then print the color name, based on the
color code given.
Switch
8
The following are the color codes and their corresponding color Statement
names.
R->Red, B->Blue, G->Green, O->Orange, Y->Yellow, W->White.
9 Switch
Write a program to receive a number and print the Statement
corresponding month name.
Example1)
C:\>java Sample 12
Example2)
C:\>java Sample
C:\>java Sample 15
13 Write a program to print prime numbers between 10 and 99. For Loop
14 For Loop
Write a Java program to find if the given number is prime or
not.
Example1)
C:\>java Sample
O/P: Please enter an integer number
Example2)
C:\>java Sample 1
O/P:1 is neither prime nor composite
Example3)
C:\>java Sample 0
O/P: 0 is neither prime nor composite
Example4)
C:\>java Sample 10
O/P: 10 is not a prime number
Example5)
C:\>java Sample 7
O/P : 7 is a prime number
I/P:1234
O/P:10
Example1)
C:\>java Sample
16 O/P: Please enter an integer number For Loop
Example2)
C:\>java Sample 3
O/P :
*
* *
* * *
17 While Loop
Write a program to reverse a given number and print
Example1)
I/P: 1234
O/P:4321
Example2)
I/P:1004
O/P:4001
Example1)
C:\>java Sample 110011
18 O/P: 110011 is a palindrome While Loop
Example2)
C:\>java Sample 1234
O/P: 1234 is not a palindrome
Topics
No. Hands-on Assignment Status
Covered
Initialize an integer array with ascii values and print the One
4 corresponding character values in a single row. dimensional
Array
9 Two
Write a program to reverse the elements of a given 2*2 array. Dimensional
Four integer numbers needs to be passed as Command Line Array
arguments.
Example1)
C:\>java Sample 1 2 3
O/P: Please enter 4 integer numbers
Example2)
C:\>java Sample 1 2 3 4
O/P:
The given array is :
1 2
3 4
The reverse of the array is :
4 3
2 1
Example1:
C:\>java Sample 1 2 3
O/P: Please enter 9 integer numbers
Two
10 Dimensional
Example2: Array
C:\>java Sample 1 23 45 55 121 222 56 77 89
O/P:
The given array is :
1 23 45
55 121 222
56 77 89
The biggest number in the given array is 222
Class and objects
No Topics
Hands-on Assignment Status
. Covered
3 Classes
Design a class that can be used by a health care professional and
to keep track of a patient’s vital statistics. The following Objects,
are the details. Constructor,
Name of the class - Patient static
Member Variables -
patientName(String),height(double),width(double)
Member Function - double computeBMI()
The above method should compute the BMI and return the result.
The formula for computation of BMI is weight (in kg) ÷
height*height(in metres).
Create an object of the Patient class and check the results.
No Topics
Hands-on Assignment Status
. Covered
Create a child class of Animal named ‘Bird’ and override the parent class methods.
Add a new method named fly().
Create an instance of Animal class and invoke the eat and sleep methods using this
object.
Create an instance of Bird class and invoke the eat, sleep and fly methods using this
object.
Inheritance 2
Create a class called Person with a member variable name. Save it in a file called
Person.java
Create a class called Employee that will inherit the Person class.The other data
members of the Employee class are annual salary (double), the year the employee
started to work, and the national insurance number which is a String.Save this in a
file called Employee.java
Your class should have the necessary constructors and getter/setter methods.
Write another class called TestEmployee, containing a main method to fully test your
class definition.
Inheritance 3
Create a school application with a class called Person. Create name and dateOfBirth
as member variables.
Create a class called Teacher that inherits from the Person class. The teacher will
have additional properties like salary, and the subject that the teacher teaches.
Create a class called Student that inherits from Person class. This class will have a
member variable called studentId.
Create a class called College Student that inherits from Student class. This class
will have collegeName, the year in which the student is studying
(first/second/third/fourth) etc.
Create objects of each of this classes, invoke and test the methods that are
available in these classes.
Inheritance
Overriding / Polymorphism
No Topics
Hands-on Assignment Status
. Covered
1 Inheritance
Create a base class Fruit with name ,taste and size as its / Overriding
attributes.
For this class, create three sub classes, Circle, Triangle and
Square and each class should override the parent class
functions - draw () and erase ().
No
Hands-on Assignment Topics Covered Status
.
2 String/StringBuffer
Write a java program that will concatenate 2 strings and
return the result. The result should be in lowercase.
Example1)
i/p:Sachin,Tendulkar
o/p:sachin tendulkar
Example2)
i/p:Mark,kate
o/p:markate
3 String/StringBuffer
Example1)
i/p:Wipro
o/p:WiWiWiWiWi
Example1)
i/p:TomCat
4 String/StringBuffer
o/p:Tom
Example2)
i/p:Apron
o/p:null
Write a java program that accepts a string and returns a
new string without the first and last character of the
input string.
5 String/StringBuffer
Example1)
i/p:Suman
o/p:uma
6 The strings will not be the same length, but they may be String/StringBuffer
empty (length 0).
7 String/StringBuffer
If the input is "xHix", then output is "Hi".
If the input is "America", then the output is "America".
8 String/StringBuffer
Example1)
i/p:ab*cd
o/p:ad
9 String/StringBuffer
Given two strings, a and b, print a new string which is
made of the following combination-first character of a,
the first character of b, second character of a, second
character of b and so on.
Any characters left, will go to the end of the result.
Example1)
i/p:Hello,World
o/p:HWeolrllod
10 String/StringBuffer
Example1)
i/p:Wipro,3
o/p:propropro
11 String/StringBuffer
Given two strings a and b, return a new string, following
the rules given below.
If string b occurs in string a, then the new string should
concatenate the characters that appear before and after of
String b.
Ignore cases where there is no character before or after
the word, and a character may be included twice if it is
in between two string b's.
Example1)
i/p:abcXY123XYijk,XY
o/p:c13i
Example2)
i/p:XY123XY,XY
o/p:13
Example3)
i/p:XY1XY,XY
o/p:11
No Topics
Hands-on Assignment Status
. Covered
1 Abstract
Create a class called GeneralBank that acts as base class for Classes
all banks. This class has getSavingsInterestRate and
getFixedDepositInterestRate methods, which returns the savings
account interest rate and fixed deposit account interest rate
that the specific bank gives. Since GeneralBank cannot say what
percentage which bank would give, make these methods abstract.
3 Abstract
Create an abstract class Instrument which is having the Classes
abstract function play.
No Topics
Hands-on Assignment Status
. Covered
Packages
Take care it should not conflict with the compartment class User
2 you have created in Abstract class exercise 2. defined
packages
No Topics
Hands-on Assignment Status
. Covered
1 Interfaces
An online library application need to be created for two types
of users/roles-Adults and children. Both of these users should
be able to register an account.
void requestBook
()
registerAccount():
requestBook():
registerAccount():
requestBook function:
2 Interfaces
Write an interface called Playable, with a method
void play();
Let this interface be placed in a package called music.
No Topics
Hands-on Assignment Status
. Covered
1 Exception
Get an input String from user and parse it to integer, if it Handling
is not a number it will throw number format exception Catch it
and print "Entered input is not a valid format for an integer."
or else print the square of that number. (Refer Sample Input
and Output).
Write a program that takes as input the size of the array and
the elements in the array. The program then asks the user to
enter a particular index and prints the element at that index.
5 throws
The method should declare that it throws ArithmeticException.
This exception should be handled in the main method.
7 Exception
A student portal provides user to register their profile. Handling:
During registration the system needs to validate the user User
should be located in India. If not the system should throw an Defined
Exception &
throw
exception.
Invoke the method registerUser from the main method with the
data specified and see how the program behaves.
Example1)
i/p:Mickey,US
o/p:InvalidCountryException should be thrown.
The message should be “User Outside India cannot be
registered”
Example2)
i/p:Mini,India
o/p:User registration done successfully
8 Exception
handling:
User
Write a program to accept name and age of a person from the
Defined
command prompt(passed as arguments when you execute the class)
Exception &
and ensure that the age entered is >=18 and < 60.
throw
Display proper error messages.
Example1) Exception
Handling:
9 Enter the 2 numbers
Finally
5 block
2
The quotient of 5/2 = 2
Inside finally block
Example2)
Enter the 2 numbers
5
DivideByZeroException caught
Inside finally block
No Topics
Hands-on Assignment Status
. Covered
1 I/O Streams
Write a program to count the number of times a character
appears in a File.
3 I/O
Anitha : 1
Harish : 1
Janani : 1
Katari : 1
Manoj : 1
Sureka : 1
Wipro : 6
at : 6
works : 6
No Topics
Hands-on Assignment Status
. Covered
Create a thread which prints 1 to 10. After printing 5, there Thread
1 should be a delay of 5000 milliseconds before printing 6 Control
Mechanism
No Topics
Hands-on Assignment Status
. Covered
Create two threads and assign names ‘Scooby’ and ‘Shaggy’ to Setting the
1 the two threads. Display both thread names. name of the
thread.