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

Introduction To Java

The document contains questions about Java programming concepts like who invented Java, Java components, variables, output of code snippets, OOP concepts, packages, data types, control structures, exceptions, threads and more. It tests fundamental Java knowledge across different topics through multiple choice questions.

Uploaded by

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

Introduction To Java

The document contains questions about Java programming concepts like who invented Java, Java components, variables, output of code snippets, OOP concepts, packages, data types, control structures, exceptions, threads and more. It tests fundamental Java knowledge across different topics through multiple choice questions.

Uploaded by

Omkar Jadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

1. Who invented Java Programming?

a. Guido van Rossum


b. James Gosling
c. Dennis Ritchie
d. Bjarne Stroustrup
2. Which component is used to compile, debug and execute the java programs?
a. JRE
b. JIT
c. JDK

d. JVM
3. Which of these cannot be used for a variable name in Java?
a. identifier & keyword
b. identifier
c. keyword
d. none of the mentioned
4. 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);
}
}

a. 32
b. 33
c. 24
d. 25
5. Which of the following is not an OOPS concept in Java?
a. Polymorphism
b. Inheritance
c. Compilation
d. Encapsulation
6. Which of these packages contains the exception Stack Overflow in Java?
a. java.io
b. java.system
c. java.lang
d. java.util
7. Which one of the following is not an access modifier?
a. Protected
b. Void
c. Public
d. Private
8. Which component is responsible for converting bytecode into machine specific
code?
a. JVM
b. JDK
c. JIT
d. JRE
9. Which component is responsible to run java program?
a. JVM
b. JDK
c. JIT
d. JRE
10. What is use of interpreter?
a) They convert bytecode to machine language code
b) They read high level code and execute them
c) They are intermediated between JIT and JVM
d) It is a synonym for JIT
11. Which of these keywords is used to define packages in Java?
a) pkg
b) Pkg
c) package
d) Package
12. Which of the following is the correct way of importing an entire package ‘pkg’?
a) import pkg.
b) Import pkg.
c) import pkg.*
d) Import pkg.*mentioned.
13. Which of the following is an incorrect statement about packages?
a) Package defines a namespace in which classes are stored
b) A package can contain other package within it
c) Java uses file system directories to store packages
d) A package can be renamed without renaming the directory in which the
classes are stored
14. Which of the following package stores all the standard java classes?
a) lang
b) java
c) util
d) java.packages
15. What is a naming convention in Java?
A. A rule for writing names of methods only
B. A rule for writing names of classes only
C. A rule for writing names of identifiers
16. Java naming convention is a suggestion only to follow
A. true
B. false
17). What the naming convention should be for Class in Java?
A. It should start with the uppercase letter.
B. It should be a noun such as Student, School, Book
C. Use appropriate words, instead of acronyms.
D. All of above
18). Which is the right naming convention for class in Java?
A. class EmployeeSalary
B. class employeeSalary
C. class Employee_Salary
D. All of above
19). How many primitive data types are there in Java programming?
A2
B3
C5
D8
20).Size of int in java is ______
A 16 bit
B 32 bit
C 64 bit
D Relies on the execution environment
21). Which is the smallest integer data type?
A int
B byte
C short
D long
22).Which is not a primitive data type in Java ?
A float
B enum
C double
D int
23).Integer Data type doesn’t incorporate following primitive data type ______.
A short
B byte
C long
D double
24). What is the size of integer in Java?
A 1 Bytes
B 2 Bytes
C 4 Bytes
D 8 Bytes
25).An statement that checks the equality only ?
A. If
B. Switch
C. If and Switch
26)."If statement" is used to test the condition.
A. true
B. false
27). Which of the following loops will execute the body of loop even when condition
controlling the loop is initially false?
a) do-while
b) while
c) for
d) none of the mentioned
28).Which of these jump statements can skip processing the remainder of the code
in its body for a particular iteration?
a) break
b) return
c) exit
29). Which of this statement is incorrect?
a) switch statement is more efficient than a set of nested ifs
b) two case constants in the same switch can have identical values
c) switch statement can only test for equality, whereas if statement can evaluate
any type of boolean expression
d) it is possible to create a nested switch statementsinue
30). Which Scanner class method is used to read integer value from the user?
a)next()
b)nextInteger()
c)nextInt()
d)readInt()
31). Which of these is used to read a string from the input stream?
a) get()
b) getLine()
c) read()
d) readLine()
32). What is the numerical range of a char data type in Java?
a) 0 to 256
b) -128 to 127
c) 0 to 65535
d) 0 to 32767
33). Which of these keywords are used for the block to be examined for exceptions?
a) check
b) throw
c) catch
d) try
34). Which of these statements is incorrect about Thread?
a) start() method is used to begin execution of the thread
b) run() method is used to begin execution of a thread before start() method
in special cases
c) A thread can be formed by implementing Runnable interface only
d) A thread can be formed by a class that extends Thread class
35). Which of the following is a superclass of every class in Java?
a) ArrayList
b) Abstract class
c) Object class
d) String
36). Which exception is thrown when java is out of memory?
a) MemoryError
b) OutOfMemoryError
c) MemoryOutOfBoundsException
d) MemoryFullException
37). What is the extension of compiled java classes?
a) .txt
b) .js
c) .class
d) .java
38). Which of the following option leads to the portability and security of Java?
A).Bytecode is executed by JVM
B).The applet makes the Java code secure and portable
C).Use of exception handling
D).Dynamic binding between objects
39) Which of the following is not a Java features?
A) Dynamic
B) Architecture Neutral
C) Use of pointers
D) Object-oriented
40) _____ is used to find and fix bugs in the Java programs.
A) JVM
B) JRE
C) JDK
D) JDB
41) Which of the following is a valid declaration of a char?
A) char ch = '\utea';
B) char ca = 'tea';
C) char cr = \u0223;
D) char cc = '\itea';
42). Which of the following tool is used to generate API documentation in HTML
format from doc comments in source code?
A). javap tool
B). javaw command
C). Javadoc tool
D). javah command
43). Which of the following for loop declaration is not valid?
A).for ( int i = 99; i >= 0; i / 9 )
B). for ( int i = 7; i <= 77; i += 7 )
C). for ( int i = 20; i >= 2; - -i )
D). for ( int i = 2; i <= 20; i = 2* i )
44) Which method of the Class.class is used to determine the name of a class
represented by the class object as a String?
A) getClass()
B) intern()
C) getName()
D) toString()
45) In which process, a local variable has the same name as one of the instance
variables?
A) Serialization
B) Variable Shadowing
C) Abstraction
D) Multi-threading
46) Which package contains the Random class?
A) java.util package
B) java.lang package
C) java.awt package
D) java.io package
47) What do you mean by nameless objects?
A) An object created by using the new keyword.
B) An object of a superclass created in the subclass.
C) An object without having any name but having a reference.
B) An object that has no reference.
48) Which option is false about the final keyword?
A) A final method cannot be overridden in its subclasses.
B) A final class cannot be extended.
C) A final class cannot extend other classes.
D) A final method can be inherited.
49) In which memory a String is stored, when we create a string using new operator?
A) Stack
B) String memory
c) Heap memory
D) Random storage space
50) Which of the following is a reserved keyword in Java?
A) object
B) strictfp
C) main
D) system
51) When an expression consists of int, double, long, float, then the entire
expression will get promoted into a data type that is:
a. float
b. double
c. int
d. long

You might also like