[go: up one dir, main page]

0% found this document useful (0 votes)
49 views20 pages

Oop

Uploaded by

sirnesateshome
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views20 pages

Oop

Uploaded by

sirnesateshome
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

1. Default, public , protected, private are?

A. Access Modifier
B. Non-access Modifiers
C. Both A and B
D. It's variable
2. Java Source Code is compiled into ______________.

A. .Obj
B. Source Code
C. Bytecode
D. .Exe
3. Single line comment starts with _________ in Java.

A. /**
B. //
C. /*
D. None of these
4. How to compile java code in command prompt?

A. javac filename.java
B. java filename.java
C. javac filename
D. java filename
5. How to run java program in command prompt?

A. javac filename.java
B. java filename.java
C. javac filename
D. java filename
6. Java is case sensitive?

A. True
B. False
C. Depends On Complier
D. May be true or false
7. What is true in Java?

A. For all class names the first letter should be in Upper Case.
B. All method names should start with a Lower Case letter.
C. Name of the program file should exactly match the class name.
D. All of the above
8. All Java components require names. Names used for classes, variables, and
methods are called?

A. Variables
B. identifiers
C. Access Modifiers
D. Java Modifiers
9. Which of the following is smallest integer data type ?

A. int
B. byte
C. short
D. long
10. Which of the following is not a primitive data type ?

A. byte
B. enum
C. short
D. int
11. Integer Data type does not include following primitive data type ____________.

A. long
B. byte
C. short
D. double
12. Character data type cannot store following value.

A. Digit
B. Letter
C. Special Character
D. String
13. Range of Byte Data Type is ____________.

A. -128 to 128
B. -127 to 127
C. -127 to 128
D. -128 to 127
14. What is size of integer in Java Programming.
A. 1 Bytes
B. 2 Bytes
C. 4 Bytes
D. 8 Bytes
15. Which of the following data type(s) can store 64 bit Value.

A. boolean
B. int
C. float
D. long
16. Short data type has a minimum value of _____________.

A. -32768
B. -32767
C. 32768
D. 32767
17. Default value of variable having boolean data type is ___________.

A. TRUE
B. FALSE
C. null
D. garbage
18. What will be the output of the program?

class Main {
public static void main(String args[]) {
int t;
System.out.println(t);
}
}
A. 0
B. garbage value
C. compiler error
D. runtime error

19. What will be the output of the program?


class Test {
public static void main(String[] args) {
for(int i = 0; 0; i++)
{
System.out.println(""Hello"");
break;
}
}
}
A. Hello
B. Empty Output
C. Compiler error
D. Runtime error
20. What will be the output of the program?

class mainclass {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
if (var1)
System.out.println(var1);
else
System.out.println(var2);
}
}
A. 0
B. 1
C. TRUE
D. FALSE

21. What is the output of this program?

class average {
public static void main(String args[])
{
double num[] = {5.5, 10.1, 11, 12.8, 56.9, 2.5};
double result;
result = 0;
for (int i = 0; i<6; ++i)
result = result + num[i];
System.out.print(result/6);

}
}

A. 16.34
B. 16.56666664
C. 16.46666667
D. 16.76666667
22. What will be the output of the program?

class increment {
public static void main(String args[])
{
int g = 4;
System.out.print(++g * 8);
}
}

A. 32
B. 36
C. 40
D. 48

23. What will be the output of the program?

class area {
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
}
}

A. 301.5656
B. 301
C. 301.56
D. 301.57
24. What will be the output of the program?

class increment {
public static void main(String args[])
{
int g = 6;
System.out.print(--g * 8);
}
}

A. 48
B. 40
C. 56
D. 44
25. A ________ provides us with named storage that our programs can manipulate.

A. data type
B. constants
C. operators
D. variable
26. To declare more than one variable of the specified type, we can use a __________
list.

A. colon-separated
B. bracket-separated
C. comma-separated
D. None of the above
27. How many kinds of variables in Java?

A. 2
B. 3
C. 4
D. 5
28. Local variables are declared in?

A. methods
B. constructors
C. blocks
D. All of the above
29. Static variables can be accessed by calling with the?

A. Object name
B. Class name
C. Function name
D. Can not say
30. Which of the following is an Example of variable initialization?

A. int a, b, c;
B. int a = 10, b = 10;
C. int 10 = a;
D. None of the above
31. Access modifiers cannot be used for local variables.

A. Yes
B. No
C. Can be yes or no
D. Cannot say
32. Which of the following can be operands of arithmetic operators?

A. Characters
B. Boolean
C. Numeric
D. Both Numeric & Characters
33. Modulus operator, %, can be applied to which of these?
A. Both Integers and floating - point numbers
B. Integers
C. Floating - point numbers
D. None of the mentioned
34. The && and || operators

A. Compare two boolean values


B. Compare two numeric values
C. Combine two boolean values
D. Combine two numeric values
35. Evaluate the value of the expression?

6 - 2 + 10 % 4 + 7

A. 14
B. 12
C. 13
D. 10
36. What is the output of this program?

class Main {
public static void main(String args[])
{
double var1 = 2 + 4;
double var2 = var1 / 4;
int var3 = 2 + 4;
int var4 = var3 / 4;
System.out.print(var2 + " " + var4);
}
}
A. 0 1
B. 1 1
C. 1.5 1
D. 1.5 1.0
37. What will be the output of the program?

class Bitwise
{
public static void main(String [] args)
{
int x = 11 & 9;
int y = x ^ 3;
System.out.println( y | 12 );
}
}
A. 7
B. 0
C. 14
D. 8
38. What is the output of relational operators?

A. Integer
B. Boolean
C. Characters
D. Double
39. Which of these is returned by "greater than", "less than" and "equal to" operators?

A. Integers
B. Floating - point numbers
C. Boolean
D. None of the mentioned
40. Which of these have highest precedence?

A. ()
B. ++
C. *
D. >>

41. What should be expression1 evaluate to in using ternary operator as in this line?

expression1 ? expression2 : expression3


A. Integer
B. Floating - point numbers
C. Boolean
D. None of the mentioned
42. What is the value stored in x in following lines of code?

int x, y, z;
x = 0;
y = 1;
x = y = z = 8;
A. 0
B. 1
C. 9
D. 8
43. What is the output of this program?

class Main
{
public static void main(String args[])
{
int x = 8;
System.out.println(++x * 3 + " " + x);
}
}
A. 24 8
B. 24 9
C. 27 8
D. 27 9
44. _________ are a sequence of characters.

A. Character
B. Strings
C. Integer
D. Classes

45. The String class is?

A. mutable
B. immutable
C. Both A and B
D. None of the above
46. Methods used to obtain information about an object are known as?

A. string methods
B. class methods
C. object method
D. accessor methods
47. Which method returns the character at the specified index?

A. int compareTo(Object o)
B. int compareTo(String anotherString)
C. char charAt(int index)
D. int compareToIgnoreCase(String str)
48. Which of these methods of String class is used to obtain character at specified
index?
A. char()
B. Charat()
C. charat()
D. charAt()
49. A __________ statement allows us to execute a statement or group of statements
multiple times.

A. array
B. loop
C. function
D. exception
50. A __________ loop statement in Java programming language repeatedly executes
a target statement as long as a given condition is true.

A. for
B. do-while
C. while
D. None of the above
51. Which loop guaranteed to execute at least one time?

A. for
B. do-while
C. while
D. All of the above
52. A for loop is useful when you know how many times a task is to be repeated.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
53. Which statement causes the loop to immediately jump to the next iteration of the
loop?

A. Exit
B. Break
C. Jump
D. Continue
54. A BREAK statement inside a Loop like WHILE, FOR, DO WHILE and
Enhanced-FOR causes the program execution ___ Loop

A. Exit
B. Continuation with next iteration
C. Never exit
D. Can not say
55. Java array is a collection of ________.

A. similar type of elements


B. different type of element
C. heterogeneous data
D. Both A and C
56. Array data access using _____.

A. Operator
B. Variable
C. index
D. Pointer
57. Java Array can allocate __________.

A. Dynamic Memory
B. Static Memory
C. Both A and B
D. None of the above
58. Which of the following is an incorrect array declaration?

A. int [] arr = new int[5].


B. int arr[] = new int[5].
C. int arr[] = new int[5].
D. int arr[] = int [5] new
59. Index in array start with ______.
A. -1
B. 0
C. 1
D. infinite
60. Which of the following is used to declare,construct, and initlaize an array?

A. int arr [] [] = {1, 2, 3, 4};


B. int [] arr = (1, 2, 3);
C. int [] arr = {};
D. int arr [] = {1, 2, 3};
61. We can calculate the length of an array using ________.

A. sizeof(array)
B. array.len
C. array.length
D. array.sizeof()
62. Which of the following is advantage of java array?

A. Code Optimization
B. Random access
C. Size No-Limit
D. Both A and B
63. In java, array elements are stored in ________ memory locations.

A. Random
B. Sequential
C. Sequential & Random
D. Binary search
64. What will be the output of the program?

class Main
{
public static void main(String args[]) {
int arr[] = {10, 20, 30, 40, 50};
for(int i=0; i < arr.length; i++)
{
System.out.print(" " + arr[i]);
}
}
}
A. 10 20 30 40 50
B. Compiler Error
C. 10 20 30 40
D. None of the above
65. Which of these is an incorrect Statement?

A. It is necessary to use new operator to initialize an array


B. Array can be initialized using comma separated expressions surrounded by
curly braces
C. Array can be initialized when they are declared
D. None of the mentioned
66. What is the type of variable "b" and "d" in the below snippet?

int a[], b;
int []c, d;
A. "b" and "d" are int
B. "b" and "d" are arrays of type int
C. "d" is int variable; and "b" is int array
D. "b" is int variable; and "d" is int array
67. How to sort an array?
A. Array.sort()
B. Arrays.sort()
C. Collection.sort()
D. System.sort()

68. How to copy contents of array?

A. System.arrayCopy()
B. Array.copy()
C. Arrays.copy()
D. Collection.copy()
69. Package in Java is a mechanism to encapsulate a ______________.

A. Classes
B. Sub Packages
C. Interfaces
D. All of the above
70. Which of these keywords is used to define packages in Java?

A. pkg
B. Pkg
C. package
D. Package
71. An _______________ statement can be used to access the classes and interface of
a different package from the current package.

A. instanceOf
B. import
C. extends
D. implement
72. Which of the following packages is used to includes classes to create user interface
like Button and Checkbox?

A. java.lang
B. java.net
C. java.awt
D. java.io
73. Which of the following packages is used to includes utility classes like Calendar,
Collection, Date?

A. java.lang
B. java.net
C. java.awt
D. java.util
74. Which of this access specifies can be used for a class so that its members can be
accessed by a different class in the same package?

A. Public
B. Protected
C. No Modifier
D. All of the mentioned
75. 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.*
76. Which of the following is false statement about package in java?

A. Packages are used for preventing naming conflicts


B. Providing controlled access: protected and default have package level access
control.
C. Packages cannot be considered as data encapsulation
D. Both B and C
77. Packages that are inside another package are the _________

A. packages
B. nested packages
C. util subpackages
D. subpackages
78. ____________ can be defined as the process where one class acquires the
properties (methods and fields) of another.

A. Overriding
B. Inheritance
C. Polymorphism
D. Abstraction
79. The class which inherits the properties of other is known as ________

A. superclass
B. parent class
C. subclass
D. None of the above
80. Subclass also known as ?

A. derived class
B. child class
C. base class
D. Both A and B
81. ___________ is the keyword used to inherit the properties of a class.

A. inherit
B. poly
C. extends
D. super
82. The super keyword is similar to _________ keyword.
83. A. construct
B. this
C. class
D. extends
84. Which of these is correct way of inheriting class A by class B?
A. class B + class A {}
B. class B inherits class A {}
C. class B extends A {}
D. class B extends class A {}

85. ______ is a way of saying: This object is a type of that object.

A. IS-A
B. HAS-A
C. ARE-A
D. HAD-A
86. A class which is declared with the ________ keyword is known as an abstract
class in Java.

A. abstract
B. util
C. extends
D. None of the above
87. A method which is declared as abstract and does not have implementation is
known as an _____________?

A. Abstract Interface
B. Abstract Thread
C. Abstract List
D. abstract Method

88. Which of these access specifiers can be used for an interface?

A. Public
B. private
C. Protected
D. All of the mentioned
89. Which of these keywords is used by a class to use an interface defined previously?
A. Import
B. import
C. implements
D. Implements
90. What type of variable can be defined in an interface?

A. public static
B. private final
C. public final
D. static final
91. What does an interface contain?

A. Method definition
B. Method declaration
C. Method declaration and definition
D. Method name

92. What type of methods an interface contain by default?

A. abstract
B. static
C. final
D. private
93. When does Exceptions in Java arises in code sequence?

A. Run Time
B. Can Occur Any Time
C. Compilation Time
D. None of the mentioned
94. Which of these keywords is not a part of exception handling?

A. finally
B. thrown
C. catch
D. try
95. Which of these keywords is not a part of exception handling?

A. finally
B. thrown
C. catch
D. try
96. Which of these keywords must be used to handle the exception thrown by try
block in some rational manner?

A. finally
B. throw
C. catch
D. try
97. Which of these keywords must be used to handle the exception thrown by try
block in some rational manner?

A. finally
B. throw
C. catch
D. try
98. Which of these is a super class of all errors and exceptions in the Java language?

A. Catchable
B. Throwable
C. RunTimeExceptions
D. None of the above
99. In which of the following package Exception class exist?

A. java.file
B. java.lang
C. java.io
D. java.util
100. Applets are designed to be embedded within an __________.

A. Javascript
B. Css
C. HTML
D. SQL
101. Which of the following is required to view an applet?

A. JCM
B. JDM
C. JVM
D. Java class
102. Which method is automatically called after the browser calls the init
method?

A. start
B. stop
C. destroy
D. paint
103. Which method is only called when the browser shuts down normally?

A. start
B. stop
C. destroy
D. paint

You might also like