JAVA basic Questions

Ace your homework & exams now with Quizwiz!

6. What is the extension of java code files? a) .js b) .txt c) .class d) .java

d) .java

What will be the output of the following Java code? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } }

Answer: aExplanation: Operator ++ has more preference than *, thus g becomes 4 and when multiplied by 8 gives 32.output: $ javac increment.java $ java increment 32

. What will be the output of the following Java program? class output { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } } a) NaN b) Infinity c) 0.0 d) all of the mentioned

Answer: d Explanation: For floating point literals, we have constant value to represent (10/0.0) infinity either positive or negative and also have NaN (not a number for undefined like 0/0.0), but for the integral type, we don't have any constant that's why we get an arithmetic exception.

8. Which environment variable is used to set the java path? a) MAVEN_Path b) JavaPATH c) JAVA d) JAVA_HOME

Answer: d Explanation: JAVA_HOME is used to store a path to the java installation.

Which one of the following is not a Java feature? a) Object-oriented b) Use of pointers c) Portable d) Dynamic and Extensible

Answer: b Explanation: Pointers is not a Java feature. Java provides an efficient abstraction layer for developing without using a pointer in Java. Features of Java Programming are Portable, Architectural Neutral, Object-Oriented, Robust, Secure, Dynamic and Extensible, etc.

1. Who invented Java Programming? a) Guido van Rossum b) James Gosling c) Dennis Ritchie d) Bjarne Stroustrup

Answer: b Explanation: Java programming was developed by James Gosling at Sun Microsystems in 1995. James Gosling is well known as the father of Java.

5. Which of these cannot be used for a variable name in Java? a) identifier & keyword b) identifier c) keyword d) none of the mentioned

Answer: c Explanation: Keywords are specially reserved words that can not be used for naming a user-defined variable, for example: class, int, for, etc.

Which component is used to compile, debug and execute the java programs?a) JRE b) JIT c) JDK d) JVM

Answer: c Explanation: JDK is a core component of Java Environment and provides all the tools, executables and binaries required to compile, debug and execute a Java Program.

2. Which statement is true about Java? a) Java is a sequence-dependent programming language b) Java is a code dependent programming language c) Java is a platform-dependent programming language d) Java is a platform-independent programming language

Answer: d Explanation: Java is called 'Platform Independent Language' as it primarily works on the principle of 'compile once, run everywhere'.


Related study sets

Chapter 8 - Commercial Property Insurance

View Set

NDG Linux Essentials - Chapter 7 - Archiving and Compression Share

View Set

Lesson 8 - damage and deterioration

View Set

Liability of Principle to Third Parties in CONTRACT

View Set

Chapter 27 - Bacteria and Archaea

View Set

EDUC 1300 Chapter 8: Learning Curve

View Set

Java Programming Final Test review

View Set

Chapter 12 Quiz Hardware and Network Troubleshooting

View Set