Q 1. Who invented Java Programming?
A. Guido van Rossum
B. Bjarne Stroustrup
C. Dennis Ritchie
D. James Gosling
Show Answer
Answer:-D. James GoslingExplanation
Java programming was developed by James Gosling at Sun Microsystems in 1995. James Gosling is well known as the father of Java.Q 2. Which statement is true about Java?
A. Java is a platform-independent programming language
B. Java is a code dependent programming language
C. Java is a platform-dependent programming language
D. Java is a sequence-dependent programming language
Show Answer
Answer:- A. Java is a platform-independent programming languageExplanation
Java is called ‘Platform Independent Language’ as it primarily works on the principle of ‘compile once, run everywhere’.Q 3. Which component is used to compile, debug and execute the java programs?
A. JRE
B. JIT
C. JDK
D. JVM
Show Answer
Answer:-C. JDKExplanation
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.Q 4. Which one of the following is not a Java feature?
A. Object-oriented
B. Use of pointers
C. Portable
D. Dynamic and Extensible
Show Answer
Answer:-B. Use of pointersExplanation
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.Q 5. Which of these cannot be used for a variable name in Java?
A. identifier & keyword
B. keyword
C. identifier
D. none of the mentioned
Show Answer
Answer:-B. keywordExplanation
Keywords are specially reserved words that can not be used for naming a user-defined variable, for example: class, int, for, etc.Q 6. What is the extension of java code files?
A .js
B .txt
C .class
D .java
Show Answer
Answer:-D .javaExplanation
Java files have .java extension.Q 8. Which environment variable is used to set the java path?
A. MAVEN_Path
B. JavaPATH
C. JAVA
D. JAVA_HOME
Show Answer
Answer:-D. JAVA_HOMEExplanation
JAVA_HOME is used to store a path to the java installation.Q 9. Which of the following is not an OOPS concept in Java?
A. Polymorphism
B. Inheritance
C. Compilation
D. Encapsulation
Show Answer
Answer:-C. CompilationExplanation
There are 4 OOPS concepts in Java. Inheritance, Encapsulation, Polymorphism and Abstraction.Q 10. What is not the use of “this” keyword in Java?
A. Referring to the instance variable when a local variable has the same name
B. Passing itself to another method
C. Passing itself to the method of the same class
D. Calling another constructor in constructor chaining
Show Answer
Answer:-C. Passing itself to the method of the same classExplanation
“this” is an important keyword in java. It helps to distinguish between local variable and variables passed in the method as parameters.Q 11. What will be the error in the following Java code?
byte b = 50; b = b * 50;
A. * operator has converted b * 50 into int, which can not be converted to byte without casting
B. b cannot contain value 100, limited by its range
C. No error in this code
D. b cannot contain value 50
Show Answer
Answer:-A. * operator has converted b * 50 into int, which can not be converted to byte without castingExplanation
While evaluating an expression containing int, bytes or shorts, the whole expression is converted to int then evaluated and the result is also of type int.Q 12 . Which of the following is a type of polymorphism in Java Programming?
A. Multiple polymorphism
B. Multilevel polymorphism
C. Compile time polymorphism
D. Execution time polymorphism
Show Answer
Answer:-C. Compile time polymorphismExplanation
There are two types of polymorphism in Java. Compile time polymorphism (overloading) and runtime polymorphism (overriding).Q 13 . What is Truncation in Java?
A. Floating-point value assigned to a Floating type
B. Floating-point value assigned to an integer type
C. Integer value assigned to floating type
D. Integer value assigned to floating type
Show Answer
Answer:-B. Floating-point value assigned to an integer typeQ 14 . What is the extension of compiled java classes?
A. .txt
B. .js
C. .class
D. .java
Show Answer
Answer:-C. .classExplanation
The compiled java files have .class extension.Q 15 . Which exception is thrown when java is out of memory?
A. OutOfMemoryError
B. MemoryError
C. MemoryOutOfBoundsException
D. MemoryFullException
Show Answer
Answer:-A. OutOfMemoryErrorExplanation
The Xms flag has no default value, and Xmx typically has a default value of 256MB. A common use for these flags is when you encounter a java.lang.OutOfMemoryError.Q 16 . Which of these are selection statements in Java?
A. break
B. continue
C. for()
D. if()
Show Answer
Answer:- D. if()Explanation
Continue and break are jump statements, and for is a looping statement.Q 17. Which of these keywords is used to define interfaces in Java?
A. intf
B. Intf
C. Interface
D. interface
Show Answer
Answer:-D. interfaceExplanation
interface keyword is used to define interfaces in Java.Q 18 . Which of the following is a superclass of every class in Java?
A. ArrayList
B. Object class
C. Abstract class
D. String
Show Answer
Answer:- B. Object classExplanation
Object class is superclass of every class in Java.Q 19. Which of the below is not a Java Profiler?
A. JProfiler
B. JVM
C. Eclipse Profiler
D. JConsole
Show Answer
Answer:- B. JVMExplanation
Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.Q 20. Which of these packages contains the exception Stack Overflow in Java?
A. java.lang
B. java.system
C. java.io
D. java.util
Show Answer
Answer:-A. java.langQ 21. Which of these statements is incorrect about Thread?
A. start() method is used to begin execution of the thread
B. A thread can be formed by a class that extends Thread class
C. A thread can be formed by implementing Runnable interface only
D. run() method is used to begin execution of a thread before start() method in special cases
Show Answer
Answer:-D. run() method is used to begin execution of a thread before start() method in special casesExplanation
run() method is used to define the code that constitutes the new thread, it contains the code to be executed. start() method is used to begin execution of the thread that is execution of run(). run() itself is never used for starting execution of the thread.Q 22. Which of these keywords are used for the block to be examined for exceptions?
A. check
B. throw
C. try
D. catch
Show Answer
daily Answer:-C. tryExplanation
try is used for the block that needs to checked for exception.Q 23. Which one of the following is not an access modifier?
A. Void
B. Protected
C. Public
D. Private
Show Answer
daily Answer:-A. VoidExplanation
Public, private, protected and default are the access modifiers.Q 24 . What is the numerical range of a char data type in Java?
A. 0 to 256
B. 0 to 65535
C. -128 to 127
D. 0 to 32767
Show Answer
daily Answer:-B. 0 to 65535Explanation
Char occupies 16-bit in memory, so it supports 216 i:e from 0 to 65535.Q 25. Which class provides system independent server side implementation?
A. Server
B. ServerSocket
C. Socket
D. ServerReader
Show Answer
daily Answer:-B. ServerSocketExplanation
ServerSocket is a java.net class which provides system independent implementation of server side socket connection.Q 26. Which of the following is true about servlets?
A. Servlets can use the full functionality of the Java class libraries
B. Servlets execute within the address space of web server, platform independent and uses the functionality of java class libraries
C. Servlets execute within the address space of web server
D. Servlets are platform-independent because they are written in java
Leave a Reply