0% found this document useful (0 votes)
18 views

JBKCORE9003-simple-basic-assignment

Uploaded by

swapnilavate2011
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

JBKCORE9003-simple-basic-assignment

Uploaded by

swapnilavate2011
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.

:8888809416

Simple Basic programs for beginners.


1. Print statements

public class DemoPrinting {


public static void main(String[] args) {
System.out.println("javabykiran");
System.out.print("Karvenagar");
System.out.println(3);
System.out.println(3 + 4);
System.out.println(3 * 4);
System.out.println(3 - 4);
System.out.println(3 / 4);
}
}

2. Write a Java program to print 'Hello' on screen and then


print your name on a separate line.

public class Exercise1 {


public static void main(String[] args) {
System.out.println("Hello Guys \n Kiran");
}
}

1|Page www.jbktest.com
www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.:8888809416

3. Write a Java program to print the sum of two numbers


and divide two numbers.

public class Exercise2 {


public static void main(String[] args) {
System.out.println(24 + 26);
System.out.println(50 / 3);
}
}

4. Write a Java program to print different types of values

public class Exercise3 {


public static void main(String[] args) {
int num;
float b;
char c;
String s;
// integer
num = 100;
// float
b = 1.234f;
// character
c = 'A';
// string
s = "Hello Java";
System.out.println("Value of num: " + num);
System.out.println("Value of b: " + b);
System.out.println("Value of c: " + c);
System.out.println("Value of s: " + s);

}
}

2|Page www.jbktest.com
www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.:8888809416

5. User defined lines printing. Bracket importance.

public class Exercise4 {

public static void main(String[] args) {


System.out.println("3/2=" + (3 / 2));
System.out.println("3/2=" + (3 / 2.0));
System.out.println("3.0/2=" + (3.0 / 2));
System.out.println("3.0/2.0=" + (3.0/ 2.0));
}

6. Variable assignment and increment and printing.

public class Exercise5 {

public static void main(String[] args) {


int a = 10;
System.out.println(a);
a = a + 2;
System.out.println(a);
a = a * 2;
System.out.println(a);
a = a - 2;
System.out.println(a);

3|Page www.jbktest.com
www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.:8888809416

7. Understanding double, character and boolean.

public class Exercise6 {

public static void main(String[] args) {


double b = 123.43555;
char c = 'e';
boolean d = true;
System.out.println("Double:" + b);
System.out.println("Character:" + c);
System.out.println("Boolean:" + d);
}

8. Understanding variable printing with and without doble quote

public class Exercise7 {


public static void main(String[] args) {
int x = 1, y = 5;
System.out.println("x");
System.out.println("y");
System.out.println("x+y");
System.out.println(x);
System.out.println(y);
System.out.println(x + y);
}

4|Page www.jbktest.com
www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.:8888809416

9. Playing with string, int, brackets and concatenation of two


strings

public class Exercise8 {

public static void main(String[] args) {


int num1 = 22;
int num2 = 8;
System.out.println(num1 + "+" + num2 + "=" + (num1 + num2));
System.out.println(num1 + "-" + num2 + "=" + (num1 - num2));
System.out.println(num1 + "x" + num2 + "=" + (num1 * num2));
System.out.println(num1 + "/" + num2 + "=" + (num1 / num2));
System.out.println(num1 + "mod" + num2 + "=" + (num1 % num2));
}

5|Page www.jbktest.com
www.thekiranacademy.com JBKCORE9003-simple-basic-assignment No.:8888809416

10. Logic for identifying positive and negative numbers

public class Exercise9 {

public static void main(String[] args) {


int input = 10;
if (input > 0) {
System.out.println("Number is positive");
} else if (input < 0) {
System.out.println("Number is negative");
} else {
System.out.println("Number is zero");
}
}

Download – [not recommended.]


https://drive.google.com/drive/folders/1B9OHWgtb9g6BQNo9IRRwMb5SkG3
hK-l7?usp=sharing

6|Page www.jbktest.com

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy