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

Java- A Cup of Coffee

The document is a study material for Class IX Computer Science at Delhi Public School, Durgapur, focusing on Java programming. It includes an introductory Java program, explanations of Java syntax, symbols, and the structure of a Java program, along with multiple-choice and subjective questions to assess understanding. Key concepts such as comments, classes, methods, and the main() method are covered, along with the significance of Java's platform independence.

Uploaded by

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

Java- A Cup of Coffee

The document is a study material for Class IX Computer Science at Delhi Public School, Durgapur, focusing on Java programming. It includes an introductory Java program, explanations of Java syntax, symbols, and the structure of a Java program, along with multiple-choice and subjective questions to assess understanding. Key concepts such as comments, classes, methods, and the main() method are covered, along with the significance of Java's platform independence.

Uploaded by

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

DELHI PUBLIC SCHOOL, DURGAPUR

Computer Science Study Material (2021-22)


JAVA- A CUP OF COFFEE
CLASS- IX

/*First program in Java to display a message on screen*/


Class FirstProgram
{
public static void main(String args[])
{
System.out.println(“Welcome to the world of Java”);
}
};

Now let me explain each and every line of the above-mentioned program.
1. The program begins with a comment to specify the program purpose. A comment is an explanatory
statement which allows you to understand the code easily. Comments do not appear in the output screen.
They are not executed. Java supports two types of comments: single-line and multi-line.
A single-line comment starts with // and the remaining line is considered in the comment.
A multi-line comment starts with /* and ends with */.

2. A class is a place holder for Java code. All the Java codes needs to be encapsulated within a class. Class
should begin with the ‘class’ keyword followed by the class name. A class name should be user-defined and
must be in CamelCase, which means First letter of every word comprising of class name should be in capital
letter.

3. Symbols used in Java programming:


{} – Curly braces. They are used to specify the block of code.
() – Parenthesis. They are used to identify a method/function. A name followed by parenthesis means it is
a method. This may/may not have parameters in it.
[] – Square brackets. They are used to identify an array.

4. A program execution begins from the main() method. In the main method you can create the object of the
defined class and have an access to the member method by using the dot(.) operator. The beginning and
ending of main method is done by using ‘{‘ and ‘}’ respectively.
public: It is an access specifier, which specifies if the method can be used by other members of the
program.
static: The Java environment should be able to call this method without creating an instance of the
class, so, this method must be declared as static.
void: The return type of this method is void, which means it will not return any value.
main: This is the beginning point of execution of the program.
String args[]: Arguments to the method must be an array of Strings, and the array is called ‘args’.

5. To display a message or a value in the output screen we use System.out.println() command.


System: It is an in-built class.
out: It is a member of the class, System.
println(): It is the method which tells the compiler to print message on the screen in a new line.
Text in quotes: A message needs to be printed as it is on the screen.
MCQs

1. What does the Java compiler translate the Java program into?
(a) Bytecode (b) HLL
(c) Code (d) Source code
2. Command javac is used for
(a) Interpretation (b) Compilation
(c) Execution (d) None of the these
3. What does JDK stand for?
(a) Java Domain Kit (b) Java Deployment Kit (c) Java Data Kit (d) Java Development Kit
4. Everything in Java is written inside __________.
(a) an object (b) variable (c) a class (d) a method
5. A single-line comment starts with:
(a) /* (b) // (c) / (d) */
6. What is the method that tells the compiler to print a message on the screen in a new line?
(a)System(b)Text in quotes(c)println()(d)out
7. In Java, what is the return type of the main() method?
(a)char(b)int (c)string(d)void
8. The process of enclosing data and methods at the same location is called:
(a)Data Hiding(b)Abstraction(c)Encapsulation(d)Polymorphism
9. Which of the following options is the correct syntax for creating an object of a class?
(a) Object object-name; (b)Object-name class-name;
(c)Class-name object-name; (d)Object-name object;
10. What is the extension of saved Java file?
(a) .java (b) .javac (c) .doc (d) .exe

Subjective Questions
1. List the key concepts of OOPs and discuss.
2. Distinguish between data abstraction and data encapsulation.
3. Define the following terms:
(a) JDK (b) JVM (c) JRE (d) JCL
4. What is the main() method in Java?
5. What is the significance of semicolon(;) in Java?
6. Define the features of Java programming language.
7. How many types of comments are there in Java?
8. Why Java is called platform-independent?

http://122.176.26.123:810/Teacher.html

You might also like