0% found this document useful (0 votes)
6 views5 pages

Gr8 Review1 WS Answerkey 2024-25

The document is a worksheet for Grade 8 Computer Science focusing on Java programming. It includes tasks for writing Java programs to display messages and patterns, identifying and correcting errors in code, and checking for errors in provided programs. The document also provides answers and corrections for the errors listed in the code examples.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Gr8 Review1 WS Answerkey 2024-25

The document is a worksheet for Grade 8 Computer Science focusing on Java programming. It includes tasks for writing Java programs to display messages and patterns, identifying and correcting errors in code, and checking for errors in provided programs. The document also provides answers and corrections for the errors listed in the code examples.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Grade 8/Computer Science/REV1/ WORKSHEET

Introduction to Java

1..Write a JAVA program to print To display the message “Welcome to Java Programming!!”
public class Message1
{
public static void main(String args[ ])
{
System.out.println("Welcome to Java Programming!!” );
}
}

2.Write a JAVA program to print the pattern as shown below.

public class RightTrianglePattern


{
public static void main(String args[])
{
System.out.print("*\n");
System.out.print("**\n");
System.out.print("***\n");
System.out.print("****\n");
System.out.print("*****\n");
System.out.print("******\n");
}

}
3.Write a JAVA program to print the pattern as shown below.

public class TrianglePattern


{
public static void main(String args[])
{
System.out.print(" *\n");
System.out.print(" * *\n");
System.out.print(" * *\n");
System.out.print(" * *\n");
System.out.print(" * *\n");
System.out.print(" ***********\n");
}
}

4.Write a JAVA program to print the pattern as shown below.

6. Write a program to declare one variable of each data type and display value in it(name, age)
public class program1
{
public static void main(String args[])
{
int age=15;
String name="Name";
char Section='A';
System.out.println("My Name is :"+name);
System.out.println("My age is :"+age);
}
}
II..List the errors in the given code
8..public class program10
public static void main (String args[])
{
int number1='4';
String 4='test';
}
Ans: int number1=4;
String ABS="test";

9.public class program11


public static void main (String args[])
{
int _number2=10;
}
Ans:No Error
10.public class program12
public static void main (String args[])
{
class String="Name";
}
Ans:String a="Name";
11.public class program13
public static void main (String args[])
{
"Name" = x String;
}
Ans:String a="Name";
12.public class program14
public static void main (String args[])
{
int @number1=600;
}
Ans:int number1=600;
13.public class program15 {
public static main(String[] args) {
System.out.println("Hello World Example);
}
}
Ans :System.out.println("Hello World Example”);

14.public class program16 {

public static void main (String args[])


{
String super="test";
}
Ans:String Super="test"; [super is a keyword]

III. Do the below programs have any errors?If yes,mention and write the output?

15. public class programa {

public static void main (String args[])


{
int _a = 10;
int $b = 20;
int C = 30;
int c = 40;
int result = _a + $b + C + c;
System.out.println("Result: " + result);

}
Ans:No errors,Result = 100
16. public class programb
{
public static void main(String[] args)
{
System.out.println("My name is:");System.out.println("Jane Doe");System.out.println("I am studying in Gr8"); }
}
Ans:My name is:
Jane Doe
I am studying in Gr8

17. public class programc


{
int x = 10;
public static void main(String[] args)
{
System.out.println("The number is" +x);
}
}
Ans:public class programc
public static void main(String[] args)
{
int x = 10;
System.out.println("The number is" +x);
}
}

*************************************************************************************************************

You might also like