Programr Code Exercises

179
4513 reads
Find Day of Given Date


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program to takes input date as [dd/mm/yyyy] formate and find out the day of entered date.

for e.g.:
1. If user gives input date 12/12/1988 then the output will be in this formate:

130
4805 reads
Number Sequence


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program which will take a number as input and prints its sequence as output.
For example if input number is 3 then program should print
12321

185
4370 reads
Consecutive number


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program or write you own code for checking the given number is
consecutive OR not. To understand better two examples are given below

203
6806 reads
Arrays and Collections


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a Java program with the following things done.
1.) Complete the logic of the program by sorting the array in ascending order.
2.) Display the output.

183
5031 reads
Exception Handling


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Correct the Java program with the following things done.
1.) Create an own exception such that if variable sum is greater than 100 it should raise an exception.

153
4183 reads
Method for finding maximum number amongst three


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Please complete the function for finding maximum number amongst the given three number.
The empty function is given in program which takes the three input integers and return the maximum number

152
4731 reads
Print traingle of * using loops


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write down the simple program to print traingle of ' * '
Depending on the user size using loops.
Eg:
please enter the size:3
the traingle is:
*
**
***

5
4148 reads
5
5228 reads
9
3778 reads
-1
3661 reads
25
6321 reads
32
7554 reads
43
4932 reads
123
4857 reads
37
16853 reads
171
530 reads
fetch chars


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Write a static method f that accepts an ArrayList containing String objects. The method should return a String containing the first character of each string in the

179
435 reads
So


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: Have you ever paid attention to the way programmers talk ? They often start their lines with 'So'.

185
413 reads
DeleteWorldCapitals


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem:
In this exercise, we have created a variable of type Map, called 'worldCapitals'. It contains the names of countries as keys and their corresponding capital as the value.

155
395 reads
Vertical Visuallization Sets


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

When this exercise is run, it will ask you to enter a line of text. We will split the line into words and put the words in a Set called 'words'.

176
469 reads
Unique


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: You recently got assigned to a new project. The project is a scientific analysis on how we write.

192
473 reads
Domain


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: Your company often gets email from college students. As a policy they would like to track all the colleges from where students are sending correspondence to your company.

205
654 reads
array reverse


Language:Java
Difficulty Level:Easy
Questions:3
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Complete the following empty recursive void method, reverse, that accepts an integer array, a starting index and an ending index, and reverses the array.
Reversing an array involves:

175
489 reads
Talking Parrot


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: You recently bought a parrot who loves to talk - a lot. You decide to write a small program where you can enter what he talks and the program tells you the number of words spoken.

180
557 reads
Grades Again


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem:
At the end of the semester, you receive an email from your teacher. She wants to meet you to discuss grades. For a moment you think she wants to admonish you for getting bad grades.

145
5478 reads
Find Maximum and Minimum Temperature


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program that takes input array daily temperatures, as floats and finds out the maximum and minimum values.

Example:

123
4253 reads
TrimSpace


Language:Java
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Write a program which takes input as string and then implement the logic to remove all the spaces in this string.

For Example :
1.If string is "This Is Programr" then the output should be:

153
4531 reads
Name search


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

Complete the following program:
two string arrays are given one is for names and other is for equivalent last names of the celebrities.

140
4877 reads
Abundant Numbers


Language:Java
Difficulty Level:Medium
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:0:30:00
Start exercise

An abundant number is a number for which the sum of its proper divisors is greater than that number.
the sum of the proper divisors of 12 would be 1 + 2 + 3 + 4 + 6 = 18,

10
3958 reads
10
4258 reads
10
6718 reads
2
3372 reads
6
3690 reads
283
6188 reads
145
465 reads
Vertical Visuallization


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

When this exercise is run, it will ask you to enter a line of text. We will split the line into words and put the words in an array called 'words'.

161
388 reads
Unnecessary


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: Your programming teacher loves creating simple problems and asking you to do them in complicated ways.

159
414 reads
Anonymous


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Anonymous inner classes are used as "one time use" classes, when we need to encapsulate some logic in a class, which is going to be used only once.

162
373 reads
Sorted Vertical Visualization


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

In this exercise we would like to read items from a Set in sorted order (not the order in which they were inserted, but in sorted order).

180
459 reads
Angry Chief


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: So, the parody we did in the last exercise, aggravated the chief scientist of your company.

137
635 reads
Operating Systems


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

1 - Linux
2 - Mac OS X
99 - Windows 7

150
591 reads
Infinity


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem:

7
4693 reads
5
4518 reads
7
3882 reads
5
4736 reads
5
4314 reads
5
3635 reads
179
4624 reads
45
4089 reads
158
474 reads
Smelling rats


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: You have been asked by your department head to smell rats. They want to find out how often the word ‘rat’ appears as part of a larger word.

157
659 reads
find duplicates


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

You are given two int variables j and k , an int array zipcodeList that has been declared and initialized by taking the inputs, and a boolean variable duplicates.

-4
4199 reads
2
4085 reads
4
5022 reads
6
4274 reads
8
4083 reads
4
3931 reads
125
512 reads
EmailVerifyer - Regular Expressions


Language:Java
Difficulty Level:Hard
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: A few months back you built the contact form for your company’s website. Your company is doing really well and a lot of people are using the contact form. However, there is a slight problem.

163
580 reads
Atleast one


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem:

3
5290 reads
5
4045 reads
126
4311 reads
113
519 reads
Rome


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Problem: Rome wasn’t built in a day, and Facebook wasn’t coded in the main method.

-2
3509 reads
2
3538 reads
4
3450 reads
60
4910 reads
106
614 reads
negative numbers


Language:Java
Difficulty Level:Easy
Questions:1
Attempts allowed:Unlimited
Available:Always
Pass rate:75 %
Time limit:0:30:00
Start exercise

Given a boolean variable named isNegative and a 2-dimensional array of ints that has been created and assigned to a2d.

3
3288 reads
3
4289 reads
5
3749 reads
197
5803 reads
226
3037 reads
triangular star


Language:Java
Difficulty Level:Hard
Questions:1
Attempts allowed:Unlimited
Available:Always
Time limit:1:00:00
Start exercise

Complete the following program for displaying the triangular output of the stars depending upon given odd input number.

Enter the number: 3

traingle is:

*-*

***

2
3655 reads
4
3403 reads
4
3597 reads
4
3371 reads
3
3284 reads
3
3431 reads
3
3953 reads
3
3413 reads
3
4044 reads
2
3192 reads
2
3780 reads
0
3344 reads
0
3257 reads
2
3080 reads
36
408 reads