20 questions
Who invented Java?
Ryan Gosling
Bjarne Stroustrup
James Gosling
Guido van Rossum
Is String a primitive data type?
Yes
No
Both
Which method to use to find length of a string?
length()
size()
long()
count()
String x = "10";
String y = "20";
String z = x + y;
System.out.println(z);
Guess the output.
1020
10 20
30
"10 20"
Choose most appropriate purpose of trim() method in String?
to remove white spaces
to get a substring of the string
to cut String at desired index
to remove extra white spaces from start and end of String
What is the most appropriate way to check if two Strings are identical?
string1 == string2
string1.equals(string2)
string1.same(string2)
string1.equalsIgnorecase(string2)
int[] myArray = {11, 22, 33, 44, 55};
which code is correct to print length of above int-array?
System.out.println(int[].myArray.length());
System.out.println(myArray.length);
System.out.println(myArray.length());
System.out.println(int[].myArray.size());
Java was originally named:
Coffee
Oak
New C++
Duke
What is the output?
int array[][] ={{9001, 2000, 1243), {77, 88, 99, 111}};
System.out.println(array[1][3]);
1243
99
111
Index out of bounds error
Multiple inheritance allows a class to inherit characteristics and features from more than one abstract parent class. This allows a subclass to extend more than one superclass, in order to use the methods of each. Java supports multiple inheritance.
True
False
This is a general structure a method.
<Returnvalue type> <Method Name> (argument / s)
<Modifier> < type> <Method Name> (parameter / s)
public static void main (String[ ] args)
<Method Name> (parameter)
The difference between static and non static method is ....
for non static method : user need to create object in a class to call a method.
A method is to perform only specific task.
There is no significant differences between static and non - static method.
Both are bounded with a class.
Explain JDK
It stands for Java Development Kit
It is the tool necessary to compile, document and package Java programs
None of the above
Both 1 and 2
What is JVM
It stands for Java Virtual Machine
It is an abstract machine. It is specification that provides run-time environment in which java bytecode can be executed
None of the above
Both 1 and 2
public is an
access modifier
keyword
return type
method
constructors has no return type in Java
True
False
Which of the following is available both in C++ and Java?
friend
try-catch-finally
interface
multiple inheritance
public inheritance
Which of the following access modifiers makes the member accessible from a class in the same package?
private
protected
public
default
Assuming Point is a valid class, what would be the result of this code: Point p[] = new Point[10]; System.out.println(p[3].getX());
0
Null Pointer Exception
-999
Index Out of Bound Error
Which are true about String?
is a primitive type
is a class
is immutable
can be instantiated without using constructors