Introduction to Java Questions Answers

Class 12 Information Technology Code 802

Introduction to Java – Important Question Answer

800+Questions XII Information Technology Code 802
Buy Chapter wise Question bank Class 12 Information Technology 802

800+Questions XII Information Technology Code 802

Que 1. What is Computer Program?

Answer: A computer program is a sequence of instructions given to the computer in order to accomplish a specific task. The instructions tell the computer what to do and how to do it.

Que 2. Give the example of five high-level programming languages.

Answer: Java, C++, Python, Ruby or Scala.

Que 3. Which language does a computer understand?

Answer: Machine Language

Que 4. What is a Compiler?

Answer: Compiler is a language processor which translates high-level language to machine language code that a computer can understand.

Que 5. What is Java?

Answer: Java is a High-Level Object Oriented programming language and has been used widely to create various types of computer applications such as database applications, desktop applications, Web-based applications, mobile applications, and games among others.

Que 6. What is Java Compiler?

Answer: A Java compiler that translates Java Source Code into Java Bytecode (a highly optimized set of instructions). Like other language compilers (c, c++), it does not translate Java code to machine language code.

Que 7. What is Java Interpreter / JVM?

Answer:  Java Interpreter is known as JVM (Java Virtual Machine). Java Interpreter translates the Java bytecode into to the respective machine code as per the operating system and then executes it.

Que 8. What is the need of JVM?  [SQP]

Answer: When the bytecode (also called a Java class file) is to be run on a computer, a Java interpreter, called the Java Virtual Machine (JVM), translates the bytecode into machine code and then executes it.

Que 9. Why java is platform independent and portable? [CBSE 2018]

Answer:  The advantage of JVM is that once a programmer has compiled a Java program into bytecode, it can be run on any platform (say Windows, Linux, or Mac) as long as it has a JVM running on it. This makes Java programs platform independent and highly portable.

Que 10. Write the full from of IDE? What is IDE?

Answer:  IDE stands for Integrated Development Environment. IDE is an integrated development environment, which combines the text editor and java compiler. It simplifying writing, compiling and executing java programs.

Que 11. Give one example of IDE.

Answer: Java NetBeans IDE.

Que 12. Write the extension of Java source code and java bytecode file.

Answer: Java Source Code: – .java  ; Java bytecode (class file) :- .class

Que 13. What is comment? How many ways you write comment in java?

Answer: Comments are non-executable statement, are used in code to document the program. Especially useful for writing the purpose of the program, so that anyone can understand it.

Comments are used for enhancing the readability of code and are ignored by the compiler when compiling a file.

You can write comments in a Java program in the following two ways:

(a) Beginning a comment line with two consecutive forward slashes (//)

(b) Writing the comment between the symbols /* and */

Que 14. How can you write single-line comments in java?

Answer: In Java single-line comment can be written by using // at the beginning of line. For example

// is used to write a single-line comment.

// this is a single-line comment

Que 15. How can you write multiline comments in java program?

Answer: In Java, the multi-line comment can be written by /*  ….. */. You need to start the comment by /* and end by */.

For example:

/* This is an

example of

a multiline comment. */

Que 16. What is package?

Answer: A package in java is a group of related classes. All classes in a package can share their data and code. Package declaration statement is the first statement in the java program.

package MyJavaProgram ;

Que 17. Why main() is special method of java?

Answer: main() function is very important component of java application program, because the execution of program is always started from the main() function.

Que 18. Which function is used to print the statement?

Answer: println() and print() function of java is use to print the message and value of variable.

Que 19. Differentiate between System.out.print( ) and System.out.println().

Answer: System.out.print() is print the message and leave the cursor in the same line, while System.out.println() is print the message and move the cursor to the next line.

Que 20. Which symbol is used in jave at the end of the statement?

Answer: The semicolon ; at the end of the statement. All Java statements must end with a semicolon.

Que 21. ________ translates the byte code into machine code and then executes it. [SQP]

Answer: Java Virtual Machine (JVM)

Que 22. _______________ is a special method that every Java application must have. [SQP]

a. Getter       b. Setter        c. Main          d. Default

Answer: Main

800+Questions XII Information Technology Code 802
Buy Chapter wise Question bank Class 12 Information Technology 802

800+Questions XII Information Technology Code 802

Que 23. Define JVM. [SQP]

Answer: Java Virtual Machine (JVM), translates the bytecode into machine code and then executes it.

Que 24. What are comment entries in Java? Mention two ways to give comments. [SQP]

Answer: Comments are used in code by programmers to document their programs – to provide explanatory notes to other people who read the code. This is especially useful in the real world, where large programs are written by one programmer and maintained by other programmers.

Beginning a comment line with two consecutive forward slashes (//)

Writing the comment between the symbols /* and */

Que 25. Why Java program is platform independent?      [SQP}

Answer: A Java compiler instead of translating Java code to machine language code, translates it into Java Bytecode. A Java interpreter, called the Java Virtual Machine (JVM), translates the bytecode into machine code and then executes it. The bytecode can be run on any platform as long as it has a JVM running on it. This makes Java programs platform independent and highly portable. (keywords bytecodes and JVM to be included)

Que 26. How can you write multiline comments in java program?  [SQP]

Answer: Writing the comment between the symbols /* and */

Que 27. Why main is a special method in the java program?  [SQP]

Answer: Main is a special method that every Java application must have. When you run a program, the statements in the main method are the first to be executed

Que 28. Why a Compiler is needed?

Answer: As you are already aware, a computer only understands its own language called “machine language”. Therefore, a compiler is needed to translate high level program code into machine language code that will be understood by the computer.

Que 29. Why we need to compile a program on every platform like Windows or Mac before execution of Program?

Answer: All platform/OS (windows, Mac) has different instruction sets, compiler is always generating the executable code as per platform. So it is required to compile every program before execution on each platform separately.

Que 30. What is the extension of Java Program File?

Answer: .java

Que 31. What is the extension of Java Bytecode File or Class File?

Answer:  .class

Que 32. What is method?

Answer: A method is a group of statements written to perform a specific task. The method body is enclosed within a pair of curly braces and contains the statements that the method will execute.

Que 33. What is the error in the given statement?

    SystemOUT.println(“Hello world”);

Answer: OUT must be ‘out’, and a dot (.) will come between System and out. The correct code is –

System.out.pirntln(“Hello World”);

Que 34. What is the error in the given statement?

    System.out.println(“Hello world”)

Answer: Missing of semicolon at the end of the statement.

In java every statement must be terminated with semicolon. The correct code is –

System.out.pirntln(“Hello World”);

Que 35. What is the error in the given statement?

    System.out.printl(‘Hello world’)

Answer: (i) printl() is not a valid function name, it should be println(), to print the line and move the cursor to the new line.

(ii) Single quote ‘’ is used for character constant, So Hello World must be enclosed with double quotes. “”.

System.out.pirntln(“Hello World”);

Que 36. Is Java a case sensitive language? Justify your answer. [CBSE 2019]

Answer: Yes, Java is a case sensitive language.

In java, ‘A’ and ‘a’ both values are treated as different because both have different ASCII / UNICODE value.

Que 37. Write any three applications where java is used. [CBSE 2017 COMPT]

Answer: Three applications are – Database applications, Desktop applications,

Web based applications, Mobile applications, and Games, etc.

Que 38. Java programs are   [CBSE 2017]

(a) Faster than others

(b) Platform independent

(c) Not reusable

(d) Not scalable

Answer: (b) Platform independent

Que 39. Java has its origin in  [CBSE 2017]

(a) C programming language

(b) PEARL

(c) COBOL

(d) Oak programming language

Answer: (a) C Programming language

Que 40. Which one of the following statements is true for Java ?  [CBSE 2017]

(a) Java is object oriented and interpreted.

(b) Java is efficient and faster than C.

(c) Java is the choice of everyone.

(d) Java is not robust.

Answer:  (a) Java is object oriented and interpreted.

Que 41. OOP features are   [CBSE 2017]

1. Increasing productivity

2. Reusability

3. Decreasing maintenance cost

4. High vulnerability

(a) 1, 2 and 4 only

(b) 1, 2 and 3 only

(c) 2, 3 and 4 only

(d) None of the above

Answer: (b) 1, 2 and 3 only

Que 42. A byte code in Java is _________.

(i) Another name for Java source file that contains the information about the hardware.

(ii) A binary code that is generated by JVM for operating system.

(iii) An intermediate code generated by Java compiler for JVM.

(iv) None of these

Answer: (iii) An intermediate code generated by Java compiler for JVM.

Que 43. Expand IDE. Name any one open source IDE for writing Java programs.

Answer: IDE stands for Integrated Development Environment.

Open Source IDE for writing Java Program –  NetBeans, Eclipse, IntelliJ IDEA, Code::Blocks, etc.

Que 44. Write any four best features of Java. [CBSE 2019 COMPT]

Answer: Four best features of Java are: –

(a)      Simple

(b)      High Level Object Oriented Programming Language

(c)      Highly Portable

(d)      Platform Independent

(e)      Secured Language

(f)       Architectural Neutral

(g)      Robust

800+Questions XII Information Technology Code 802
Buy Chapter wise Question bank Class 12 Information Technology 802

800+Questions XII Information Technology Code 802

You cannot copy content of this page

Scroll to Top