Name: ________________________________________ Date: __________________
Section: _____________ Roll No.: _______________
La Martiniere Girls’ College
Class VIII
Computer Science
Java Programming – Output Questions
System.out.print("Learning "); int a = 10, b = 5;
System.out.println("Java Programming."); int result = (a + b) * (a - b) / a;
System.out.print("It is "); System.out.println("Result: " + result);
System.out.print("fun and ");
System.out.println("challenging!");
Output – Output –
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
int a = 50, b = 25;
int m = 7;
System.out.println("Initial value of a = " + a);
int n = 9;
int temp = a / 5;
System.out.println(m + n);
a = a + 20;
System.out.println("7" + "9");
System.out.println("Updated value of a = " + a);
System.out.println("" + m + n);
int product = a * b;
System.out.println(7 + 9 + m + " " + n + m);
System.out.println("Value of temp is: " + temp);
System.out.println("Sum: " + m + n);
System.out.println("Value of product is: " +
System.out.println("Sum: " + (m + n));
product);
Output – Output –
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
LMGC/Cl 8/COMPUTER SCIENCE /Practical 3 Page 1 of 2
char a = '$' , b = '%'; int num = (20 + 30) * 2;
String u = "##Answer##"; String k = "45";
System.out.println(u); System.out.println( k + num );
System.out.print("1" ); System.out.println( "num" + num );
System.out.println(". " + a); System.out.println( num-10);
System.out.println("2. " + b); System.out.println( num-5 + "_" + k+5 );
Output – Output –
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
int a = 10, b = 30;
int x = 10, y = 25, z = 8, p, q, r; float a1 = (a + b) * 4;
p = (x - z) + 10; float a2 = (a + 22) % b;
y = y - 10; int b1 = (a + b) / 4;
q = x * y; int b2 = (a * a) + (b * b);
r = q - z; System.out.println("1) " + a1);
System.out.println("p= " + p); System.out.println("2) " + a2);
System.out.println("q= " + q); System.out.println("3) " + b1);
System.out.println("r= " + r); System.out.println("4) " + b2);
Output –- Output –
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
______________________________________ _________________________________________
LMGC/Cl 8/COMPUTER SCIENCE /Practical 3 Page 2 of 2