0% found this document useful (0 votes)
14 views4 pages

Scratch A To Z

Scratch program
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)
14 views4 pages

Scratch A To Z

Scratch program
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/ 4

Dept.

of Computer Science
Class- VIII

Ch 4. Program Coding
Unit 3: Compiling and Executing program

1. Explain the basic structure of Java Programming.


Ans- The basic format of writing a program in Java is:
Declaration of class: It contains the word, access specifier (i.e.
public). It also defines the keyword 'class' which is followed by a
meaningful class name.
The opening of the bracket indicates the beginning of a class and
the main function.
Declaration of main function: It contains the data by which
execution of Java statements take place. It contains input stream
and output.
Termination of each statement must be indicated with a semi-
colon.
Closing of the curly bracket indicates the closing of the main
function and the class.

2. How to write comments in Java program?


Ans- There are three ways to write comment in Java program. These are:
Single Line Comment- In this system, the comment or remark is
stated within a single line string with double slashes (//).

Multiline Comment- Sometimes, it may happen that the comment


statement cannot be completed within a line and may take more
lines. In such a case, a multiline comment statement is used. This
comment statement starts with (/*) and ends with (*/).

Documenting Comment- While programming, sometimes we may


need to include some text documents. This can be made possible by
using documenting comment. This comment starts with (/**) and
ends with (*/).

Class-VIII
Page 1
3. How to write Output Statement in Java program?
Ans- The statement which is used to get the output of the program or to
display messages on the screen, is given as:
System.out.println();
Syntax: <Output statement><message or message with a variables>
E.g. System out.println("Welcome to Java Programming");
Output: Welcome to Java Programming

4. What isBlueJ? Write few features of BlueJ.


Ans- BlueJ is a free Java environment from Monash University, Australia. It
is a window platform for Java Development Kit (IDK ).
Some of the features of BlueJ are:
The compilation as well as execution of the program is comparative
than JDK 1.3 platform.
It is a window-based platform where the user can perform the tasks
more conveniently.
When a class is declared, it facilitates a sample program to give a
brief idea of programming.
Debugging can also be done easily as it indicates the errors at the
bottom of the same window.
It also supports the syntax of the program which is written on JDK
1.3 DOS based.

5. Explain Java programming by using Function Argument.


Ans- This is one of the methods to accept the value from the user at the time
of execution of the program. The variables must be defined within main () as
arguments. Example:
public static void main(int a, int b)
//This function will accept two values from the user belonging to the
defined data type and after manipulation, the output of the program is
obtained on the screen.

6. Explain Java programming by using Stream Classes.


Ans- This system provides user-friendly environment to input the data values
in Java programming during execution of the program. This system applies
two types of classes, viz. 'InputStream' and 'BufferedReader'.

InputStream class- The data given to the computer is converted into


the machine code, i.e. binary form. This machine code needs to be
transferred to the CPU in terms of a binary bit pattern. Hence, the
system tries to streamline the bits so that they do not get disturbed
or hampered and cause any input error. The streamlining of bits are

Class-VIII
Page 2
done by using InputStream class.

BufferedReader class- A computer system has a high speed buffer


device ( a temporary storage device) in between input unit and the
processor. In order to synchronize the speed of 1/O devices and the
processor, buffer allows storing of input streamlined bit pattern so
that the instant supply of data can be done to the CPU without any
delay. Thus, the BufferedReader class is used.

7. Explain the terms:


public: It is the key word used to specify that the function has no
restriction on being used anywhere throughout the system.
static: This key word states that the function needs no object
created for its use.
void: It refers to the non-returnable type of function, te, the function
w not return any value.
main: It is the function name. The main function is called by default
from the system. As soon as the command to execute a program is
issued, the control by default jumps to the main function for its
execution.
String args(): This is an args[] array that receives the values input
from the keyboard as a String data.
Throws IOException: Sometimes, the program experiences errors
even if the programming statements have correct syntax. It
eliminates the 1/0 errors (if any) that creep while programming.
InputStreamReader read = new InputStreamReader(System.in);:
This statement creates an object of InputStream type (say, read) to
accumulate streamlined bit pattern from the input device.
BufferedReader in = new BufferedReader(read);: This statement is
used to create an object 'in of BufferedReader type to store the input
data from the keyboard temporarily.

8. Explain types of Java Errors:


Ans- While writing a Java program, one or more errors may crept in. These
errors may be typing errors, wrong usage of variables ete.
Syntax Error- Most syntax errors are caused by mistakes that we
make when typing the code. These errors are also known as
Compilation errors. For example, semicolon () is not given after a
complete statement.
Runtime Error- These errors will occur when program attempts an

Class-VIII
Page 3
operation that is impossible to carry out the program execution
time. For example, a program error may result from an attempt to
divide by zero.
Logical Error- These errors will occur when the output of an
operation may produce unwanted or unexpected results for the
entered set of input data. For example, expecting difference
between two numbers as output but operation performs for addition

----------------End of Note----------------

Class-VIII
Page 4

You might also like