Java Basics-1
Java Basics-1
1. Write a Java program to print 'Hello' on screen and then print your name on
a separate line.
Expected Output :
Hello
Sterling Institute
3. Write a Java program to divide two numbers and print on the screen.
Test Data :
50/3
Expected Output :
16
STERLING INSTITUTE
G-5, 150 New Azad Nagar Behind Akashwani, Daly College Road Indore – 452001
Contact: +91 9109913455
www.sterlinginstitute.in
4. Write a Java program to print the result of the following operations.
Test Data:
i. -5 + 8 * 6
ii. (55+9) % 9
iii. 20 + -3*5 / 8
iv. 5 + 15 / 3 * 2 - 8 % 3
Expected Output :
43
1
19
13
6. Write a Java program to compute the specified expressions and print the
output.
Test Data:
((25.5 * 3.5 - 3.5 * 3.5) / (40.5 - 4.5))
Expected Output
2.138888888888889
STERLING INSTITUTE
G-5, 150 New Azad Nagar Behind Akashwani, Daly College Road Indore – 452001
Contact: +91 9109913455
www.sterlinginstitute.in
7. Write a Java program to print an American flag on the screen.
Expected Output
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
* * * * * ==================================
* * * * * * ==================================
==========================================
==========================================
==========================================
==========================================
==========================================
*
* *
* *
* *
* * * * * * * * *
STERLING INSTITUTE
G-5, 150 New Azad Nagar Behind Akashwani, Daly College Road Indore – 452001
Contact: +91 9109913455
www.sterlinginstitute.in
9. Write a program to print Inverted Pyramid Star Pattern?
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
* * * * * * * * * *
* * * * * * * *
* * * * * *
* * * *
* *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
STERLING INSTITUTE
G-5, 150 New Azad Nagar Behind Akashwani, Daly College Road Indore – 452001
Contact: +91 9109913455
www.sterlinginstitute.in
12.Write a program to print Plus Star Pattern?
+
+
+
+
+ + + + + + + + +
+
+
+
+
STERLING INSTITUTE
G-5, 150 New Azad Nagar Behind Akashwani, Daly College Road Indore – 452001
Contact: +91 9109913455
www.sterlinginstitute.in