0% found this document useful (0 votes)
25 views106 pages

L1 MCQ's

The document consists of a series of multiple-choice questions and answers related to programming concepts, primarily focusing on Java and JavaScript. Each question tests knowledge on specific programming scenarios, syntax, and concepts, with correct responses indicated. The overall score for each question is noted as 1.00, suggesting that the responses provided are correct.

Uploaded by

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

L1 MCQ's

The document consists of a series of multiple-choice questions and answers related to programming concepts, primarily focusing on Java and JavaScript. Each question tests knowledge on specific programming scenarios, syntax, and concepts, with correct responses indicated. The overall score for each question is noted as 1.00, suggesting that the responses provided are correct.

Uploaded by

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

Question Results

Score 1.00 of 1
Question:
When the switch statement matches the expression with the given labels,
how is the comparison done?
Response:

Both the datatype and the result of the expression are compared
Only the datatype of the expression is compared
Only the value of the expression is compared
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet?a = [1, 2, 3, 4,
5];print(a.slice(2, 4));
Response:

3, 4
2, 3
3, 4, 5
2, 3, 4
Score 1.00 of 1
Question:
What will be the output of the following code snippet?<script
type="text/javascript" language="javascript"> var x=12;var y=8;var
res=eval("x+y");document.write(res); </script>
Response:

20
x+y
128
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet?let sum = 0;
const a = [1, 2, 3];a.forEach(getSum);print(sum);function getSum(ele) {
sum += ele;}
Response:

6
1
2
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet?(function(){
setTimeout(()=> console.log(1),2000); console.log(2); setTimeout(()=>
console.log(3),0); console.log(4);})();
Response:
1234
2341
2431
4321
Score 1.00 of 1
Question:
What will be the output of the following code snippet?var a =
Math.max() < Math.min();var b = Math.max() >
Math.min();print(a);print(b)
Response:

true false
false true
true true
false false
Score 1.00 of 1
Question:
Which of the following methods is used to access HTML elements using
Javascript?
Response:
getElementbyid()
getElementsByClassName()
Both A & B
None of the above
Score 1.00 of 1
Question:
The loop will run 3 times, before meeting the exit condition. First
value of b will be 2 * 2 = 4, followed by 4 + 3 * 2 = 10, and then
value of 10 + 4 * 2 = 18.
Response:
It will debug all the errors in the program at runtime
It acts as a breakpoint in a program
It will debug erroe in the current statement if any
All of the above
Score 1.00 of 1
Question:
Upon encountering empty statements, what does the Javascript
Interpreter do?
Response:
Throws an error
Ignores the statements
Gives a warning
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet? <script
type="text/javascript">a = 5 + "9";document.write(a);</script>
Response:
Compilation Error
14
Runtime Error
59
Score 1.00 of 1
Question:
What will be the output of the following code snippet?(function(a){
return (function(){ console.log(a); a = 6; })()})(21);
Response:
6
NaN
21
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet?function
solve(arr, rotations){ if(rotations == 0) return arr; for(let i = 0; i
< rotations; i++){ let element = arr.pop(); arr.unshift(element); }
return arr;}// solve([44, 1, 22, 111], 5);
Response:
[111, 44, 1, 22]
[44, 1, 22, 111]
[111, 44, 1, 22]
[1, 22, 111, 44]
Score 1.00 of 1
Question:
What does the 'toLocateString()' method do in JS?
Response:
Returns a localised object representation
Returns a parsed string
Returns a localized string representation of an object
None of the above
Score 1.00 of 1
Question:
What will be the output of the following code snippet?var a = true +
true + true * 3;print(a)
Response:
3
0
Error
5
Score 1.00 of 1
Question:
What will be the output of the following code
snippet?print(typeof(NaN));
Response:
Object
Number
String
None of the above
Score 1.00 of 1
Question:
What is the output of the following code snippet?print(NaN === NaN);
Response:
TRUE
FALSE
undefined
Error
Score 1.00 of 1
Question:
When an operator's value is NULL, the typeof returned by the unary
operator is:
Response:
Boolean
Undefined
Object
Integer
Score 1.00 of 1
Question:
What will be the output for the following code snippet?<p
id="example"></p> <script> function Func() {
document.getElementById("example").innerHTML=Math.sqrt(81); } </script>
Response:

9
81
Error
0
Score 1.00 of 1
Question:
What will be the output of the following code snippet? <script
type="text/javascript" language="javascript"> var a = "Scaler";var
result = a.substring(2, 4);document.write(result); </script>
Response:

al
ale
cal
caler
Score 1.00 of 1
Question:
What will be the output of the following code snippet?var a = 1; var b
= 0; while (a <= 3) { a++; b += a * 2; print(b);}
Response:

4 10 18
123
147
None of the above
Question Results
Score 1.00 of 1
Question:
Given the following definition of a class, which fields are accessible
from outside the package com.corporation.project?package
com.corporation.project;public class MyClass{int i;public int
j;protected int k;private int l;}
Response:

Field j is accessible in all classes in other packages


Field i is accessible in all classes in other packages
Field k is accessible in all classes in other packages
Field l is accessible in all classes in other packages
Field l is accessible in subclasses only in other packages.
Score 1.00 of 1
Question:
Which are valid steps to take to enable JPA in spring boot
Response:
Add @EnableJPAEntities to configuration class
Add an @EnableJPARepositories annotation to configuration class
Add @EnableDbFunctionalities annotation to configuration class
Add @InitJPAEntities to configuation class
none of the above
Score 1.00 of 1
Question:
What is DispatcherServlet
Response:
The DispatcherServlet API assigns a separate webservlet node to each additional
HTTP request that comes into the web server
It is a servlet that dispatches HttpRequests to registered handler/controllers for
processing
It is a servlet used for security
It is used to process REST requests
none of the above
Score 1.00 of 1
Question:
What is the purpose of Spring IoC container
Response:
IT allows front-end code to manage the ResponseBody objects provided by a
backend-rest API
It instantiates and configure objects,supplied at runtime,to classes that define
them as dependency
It allows database to define business objects via a shared schema at compile time
It facillitates a remote server to configure a local application
none of the above
Score 1.00 of 1
Question:
Which property of spring boot is used to change port of a spring
application
Response:

server.port
spring.port
port
server
server.spring.port
Score 1.00 of 1
Question:
How many objects will be created in the following?String a = new
String("Interviewbit");String b = new String("Interviewbit");Strinc c =
"Interviewbit";String d = "Interviewbit";
Response:

3
2
4
5
1
Score 1.00 of 1
Question:
Look at the below given code @Entity@Table(name =
"EMPLOYEE")@Access(value=AccessType.FIELD)public class Employee
{@Id@GeneratedValue(strategy = GenerationType.IDENTITY)@Column(name =
"emp_id")private long id;@Column(name = "emp_name")private String
name;@OneToOne(mappedBy = "employee")@Cascade(value =
org.hibernate.annotations.CascadeType.ALL)private Address
address;//getter setter methods} which of the statement are correct
regarding above code
Response:
A table Employee will be generated with no colum
A table employee will be gnerated with name column
A table with name Employee will be generated having attributes id and name
having OneToOne relation with Address entity
A table Employee will be generated with id column
no table will be generated
Score 1.00 of 1
Question:
package samplequestions;public class Sample {public static void
main(String[] args) {// TODO Auto-generated method stubint[] x = {120,
200, 016}; for(int i = 0; i < x.length; i++){ System.out.print(x[i] + "
");}}}
Response:
120 200 16
120 200 14
120 200
200 16
12 16
Score 1.00 of 1
Question:
Identify the infinite loop.
Response:
for(;;)
for(int i=0;i<!0;i--)
for(int i=0;;i++)
All of the above
none of the above
Score 1.00 of 1
Question:
Predict the output of below codepackage samplequestions;public class
Sample {public static void main(String[] args) {int count = 0;do{
System.out.println("Interviewbit"); count++;} while(count < 10);}}
Response:

Interviewbit will be printed 10 times


Interviewbit will be printed 11 times
Interviewbit will be printed 09 times
Interviewbit will be printed 11 times
compile time error
Score 1.00 of 1
Question:
Core Java Multiple Choice Questions # 33) What will be the result of
attempting to compile the following program?public class MyClass {long
var;public void MyClass(long param) { var = param; } //(1)public static
void main(String[] args) {MyClass a,b;a = new MyClass(); //(2)b = new
MyClass(5); //(3)}}
Response:
A compilation ERROR will occur at (1), since constructors cannot specify a
return value
A compilation error will occur at (3), since the class does not have a constructor
which takes one argument of type int
A compilation error will occur at (2), since the class does not have a default
constructor
The program will compile correctly
The program will compile and execute correctly.
Score 1.00 of 1
Question:
What does the following string do to given string str1.String str1 =
"Interviewbit".replace('e','s');
Response:

replaces all occurences of e to s


replaces single occurences of e to s
replace single occurrence of s to e
compile time error
run time error
Score 1.00 of 1
Question:
Predict the output of below codepackage samplequestions;public class
Sample {public static void main(String[] args) {int[] a =
{0,2,4,1,3};for(int i = 0; i < a.length; i++){ a[i] = a[(a[i] + 3) %
a.length];} for(int i=0;i<a.length;i++) { System.out.println(a[i]);
}}}
Response:

11431
1 4 3 11
14131
11111
144 331
Score 1.00 of 1
Question:
what is the error in the following class definitions?abstract class
xy{abstract sum (int x, int y) { }}
Response:
class cannot be abstract
abstract method cannot have body
method cannot be abstract
we cannot have abstract method inside abstract class
none of the above
Score 1.00 of 1
Question:
Which one of the following class definitions is a valid definition of a
class that cannot be instantiated?
Response:

abstract class Ghost{void haunt() { };}


class Ghost{abstract void haunt();}
abstract class Ghost{void haunt();}
abstract Ghost{abstract void haunt();}
static class Ghost{abstract haunt();}
Score 1.00 of 1
Question:
What is RESTful web service
Response:
Representational state transfer an architectural style for creating a web service
that includes client server architecture ,stateless ,cacheabiliity,a layered system
and a uniform interface
Reactive enterprices status transfer is an architectural style for creating a web
service that includes client server architecture ,stateless ,cacheabiliity,a layered
system and a uniform interface
Redundant enumerative state transfer is an architectural style for creating a web
service that includes client server architecture ,stateless ,cacheabiliity,a layered
system and a uniform interface
Reactive enumerative state transfer is an architectural style for creating a web
service that includes client server architecture ,stateless ,cacheabiliity,a layered
system and a uniform interface
none of the above
Score 1.00 of 1
Question:
Look at the code below @Entitypublic class User { @Id
@GeneratedValue(strategy = GenerationType.AUTO) private Long id;
private String firstName; private String lastName; // TODO} what will
the Id annotation do
Response:
mark class as entity
mark id attribute as primary key
mark entire class as Embeddable
it is a mandatory annotation for class and can be kept over any attribute
It is an optional annotation
Score 0.00 of 1
Question:
String s1 = " yes" ;String s2 = " yes " ;String s3 = new String ( s1);
as per above code ,which of the above statements are correct
Response:

s1==s2
s1!=s2
s1=s2
s1==s3
s2==s3
Score 0.00 of 1
Question:
What's true about the following @Entity association between House and
Window?@Entitypublic class Window {@Idprivate int
winNo;@ManyToOneprivate House aHouse;}@Entitypublic class House
{@Idprivate int houseNo;@OneToMany(mappedBy="aHouse")private List
windows;
Response:
It's OneToMany unidirectional association
The association owner is the House class
The association owner is the Window class
The association owner is the Window class
none of the above
Score 1.00 of 1
Question:
What does ViewResolver do
Response:
It generates a view by mapping a logical view name returned by a controller
method to a view technology
It supports internatinalization of web applications by detecting a user's locale
It creates a unique view determined by the user's browser type ,supporting cross
browser compatibility
It maps custom parameter to SQL views in database
none of the above
Score 1.00 of 1
Question:
Predict the output of below codepackage samplequestions;public class
Sample {public static void main(String[] args) {// TODO Auto-generated
method stub byte x = 127; x++; x++; System.out.print(x);}}
Response:
127
-127
0
-1
compile time error
Score 1.00 of 1
Question:
Which of these field declarations are legal within the body of an
interface?
Response:
public int val=100
int val=100
public static final int val=100
public static int val=100
none of the above
Score 1.00 of 1
Question:
Predict the output of below codepackage samplequestions;public class
Sample {public static void main(String[] args) {String str =
"abcde";System.out.println(str.substring(1, 3));}}
Response:
abc
bc
abcd
bcd
cde
Score 1.00 of 1
Question:
How does Spring generate bean names for classes annotated with
@Component that do not specify a name
Response:
It uses sort name of the classes
It uses short name of the class in upper case
It uses cannonical name of the class in lower case
It uses short name of the classes with first letter in lower case
A bean cannot be created for such a class
Score 1.00 of 1
Question:
Predict the output of below codepackage samplequestions;public class
Sample {public static void main(String[] args) {// TODO Auto-generated
method stubString str;int fname;str="Foolish
boy";fname=str.indexOf("fool"); System.out.println(fname);}}
Response:
0
3
1
-1
2
Question Results
Score 1.00 of 1
Question:
How to auto-inject in an attribute a bean by its name?
Response:
With the name attribute of the @Autowired annotation
Using the unique @Qualifier annotation
Using the @Autowired and @Qualifier spring annotations
Score 1.00 of 1
Question:
Which of the following is correct output?public class DemoFun {public
static void main(String[] args) { List<Integer> numbers =
Arrays.asList(2,3,4,5,2); Set<Integer> squareSet =
numbers.stream().map(x->x*x).collect(Collectors.toSet());
System.out.println(squareSet);}}
Response:

a) [16, 4, 9, 25]
b) [16,4,9,25,4]
c) [4,9,16,25,4]
d) [4,4,16,25,9]
Score 0.00 of 1
Question:
Given below code snippetFor the Given Code snippet () -> 7 * 12.0;
Which of the following interfaces can provide the functional descriptor
for the above lambda expression?
Response:
a) interface A { default double m() { return 4.5; }}
b)interface B { int m(int a,int b);}
c) interface C { int m();}
d)interface D { double m(Integer... i);}
Score 1.00 of 1
Question:
What's true about the following @Entity association between House and
Window?public class Window { @Id private int winNo; @ManyToOne private
House aHouse;}@Entitypublic class House { @Id private int houseNo;
@OneToMany(mappedBy="aHouse") private List windows;}
Response:
It's OneToMany unidirectional association
It's OneToMany bidirectional association
The association owner is the House class
The association owner is the Window class
Score 1.00 of 1
Question:
Choose the output for following code snippet.public class DemoFun
{public static void main(String[] args) { Stream.of("eeny ", "meeny ",
null).forEach(DemoFun::toUpper); } private static void toUpper(String
str) { Optional <String> string = Optional.ofNullable(str);
System.out.print(string.map(String::toUpperCase).orElse("dummy")); }}
Response:

A)This program prints: EENY MEENY dummy


B. This program prints: EENY MEENY DUMMY
C. This program prints: EENY MEENY null
D. This program prints: Optional[EENY] Optional[MEENY] Optional[dummy]
Score 1.00 of 1
Question:
Select the correct output of the execution of the below program:public
class Test {public static void main(String[] args) {Set s = new
HashSet();s.add(new Long(10));s.add(new Integer(10));for(Object object
: s) { System.out.println("test - "+object);}}}
Response:

a) test-10 test-10
b) test-10
c)RunTimeException
d)Compilation Failure
Score 1.00 of 1
Question:
Consider the following code:
public class MyClass { private boolean check(String arg) { System.out.println(arg); assert arg !=
null; // Line 1 return !arg.isBlank(); } String m1(String arg) { assert arg != null; // Line 2 // do
something assert check(arg); // Line 3 return arg.trim(); } public String m2(String arg) { assert arg
!= null; // Line 4 String output = m1(arg); assert output != null; // Line 5 return output; } }
On which three lines assertions are used properly?
Response:
Lines 1, 2 & 3
Lines 3, 4 & 5
Line 1, 2 & 5
Line 2, 3 & 5
Score 1.00 of 1
Question:
class Employee {
int id;
String name;
public Employee() { }
public Employee(int id, String name) {
this.id = id; this.name = name; } //setters and getters}
public class ComparableTest {
public static void main(String[] args) {
List list = new ArrayList<>();
list.add(new Employee(123, "Sugan"));
list.add(new Employee(101, "Kavita"));
list.add(new Employee(132, "Anju"));
Comparator comparator = (a, b) -> { return a.getName().compareTo(b.getName()); };
list.sort(comparator); list.forEach(e -> System.out.println(e.getName())); }}
Response:
SuganKavitaAnju
AnjuKavitaSugan
KavitaSuganAnju
Compilation fails
Score 1.00 of 1
Question:
Predict the output. import java.util.ArrayList;public class
CollectionFramework { public static void main(String argvs[]) {
ArrayList al = new ArrayList(); al.add("X"); al.add("Y"); al.add("Z");
al.add(1, "B"); System.out.print(al); }}
Response:
[X, Y, B, Z]
[X, B, Z]
[X, B, Y, Z]
[X, Z, Y, B]
Score 0.00 of 1
Question:
Which one of the following are not valid lambda expression?
Response:
() -> {}
() ->"Hello"
{return "Hello"•;}
(Integer i) -> return Hello"
Score 1.00 of 1
Question:
public class ForEachExample {
public static void main(String[] args) {
List gamesList = new ArrayList();
gamesList.add("Football"); gamesList.add("Cricket");
gamesList.add("Chess"); gamesList.add("Hocky");
gamesList.add("Cricket"); gamesList.add("Chess");
gamesList.add("Football"); gamesList.add("null");
gamesList.add(null);
Set set = gamesList.stream().collect(Collectors.toSet()); set.forEach(game ->
System.out.println(game)); }}
Response:

ChessHockynullCricketnullFootball
ChessHockynullCricketFootball
FootballCricketChessHockyCricketChessFootballnull
FootballCricketChessHockyCricketChessFootballnullnull
Score 1.00 of 1
Question:
Which is the new method introduced in java 8 to iterate over a collection?
Response:
for (String i : StringList)
foreach (String i : StringList)
StringList.forEach()
List.for()
Score 0.00 of 1
Question:
Suppose you have to get the names with course and age where age is
neither 25 nor 26. Which of the following is the correct query for
this?
Response:
SELECT Names FROM Students WHERE Age NOT EXISTS (25', '26')
SELECT Names FROM Students HAVING Age NOT EXISTS (25', '26')
Score 1.00 of 1
Question:
Which of the given option is correct for adding exception to the test
method given below? Public void
divideByZeroTest(){calobj.divide(15,0);} Note: calobj is an object of
Calculate class which contains divide(int x,int y) method.
Response:

@Test(expected = ArithmeticException.class)
@Test( ArithmeticException.class)
@Before( ArithmeticException.class)
@Before(expected = ArithmeticException.class)
Score 1.00 of 1
Question:
Suppose you have to get the Name, Age and Salary of the Employees with salaries
in the range
of 30000 to 50000. Which of the following queries would be correct for this?
Response:

SELECT * FROM Employees WHERE Salary BETWEEN 30000 AND 50000


SELECT * FROM Name HAVING Salary BETWEEN 30000 AND 50000
Score 1.00 of 1
Question:
In the Given Code Snippet (s) -> System.out.println("Welcome to Java 8,
Hello !!! "+s); is an implementation of type
Response:
a)java.util.function.Supplier
b)java.util.function.Function
c)java.util.function.Consumer
d)java.util.function.Predicate
Score 1.00 of 1
Question:
Consider the tables :Item (id, iname), Market (id, number)The following
queries were executed on these tables :1. SELECT I.id, M.number FROM
ITEM I INNER JOIN MARKET M ON I.id = M.id;2. SELECT I.id, M.number FROM
ITEM I LEFT OUTER JOIN MARKET M ON I.id = M.id;3. SELECT I.id, M.number
FROM ITEM I RIGHT OUTER JOIN MARKET M ON I.id = M.id;4. SELECT I.id,
M.number FROM ITEM I FULL OUTER JOIN MARKET M ON I.id = M.id;One of the
above queries will have an output that will include the outputs of the
other three queries. Identify it.
Response:
Option 1
Option 4
Score 1.00 of 1
Question:
A functional interface acts as target types for which of the
following?Option 1: Lambda expressionOption 2: Method referenceOption
3: Constructor reference
Response:
Options 1 & 2 only
Options 1 & 3 only
Options 2 & 3 only
Options 1, 2 & 3
Score 0.00 of 1
Question:
Which of the following statements are TRUE regarding the COUNT ()
function in SQL?
Response:
COUNT(Prod_id) returns the number of rows including rows with duplicate
products Id and NULL value in the Prod_id column.
COUNT (Distinct Prod_id) returns the number of rows excluding rows
containing duplicates and NULL values in the Prod_id column.
Score 1.00 of 1
Question:
Choose the best option based on this program:import
java.util.function.BiFunction;import java.util.stream.Stream;public
class DemoFun {public static void main(String[] args) {// TODO Auto-
generated method stubBiFunction < String, String, Boolean >
compareString = (x, y) ->x.equals(y);
System.out.println(compareString.apply("Java8", "Java8")); // #1}}
Response:
A. This program results in a compiler error in the line marked with #1
B. This program prints: true
C. This program prints: false
D. This program prints: (x, y) -> x.equals(y)
Score 1.00 of 1
Question:
Which of the following options can be added to line 4 for the code to
compile and run correctly?var list = new ArrayList<String>();
list.add("one"); list.add("two"); // line 4 - Add code here for (var s
: list) System.out.print(s);
Response:
list.add(Integer.valueOf(3));orlist.add(3,"3");
list.add(3);orlist.add(Integer.valueOf(3));
list.add(String.valueOf("3"));orlist.add(2,"two");
list.add(3,"3");orlist.add(3);
Score 1.00 of 1
Question:
Which Comparator is defined correctly for the given class?class
Painting {Integer width = 0;String name;Painting(String name, Integer
width) {this.name = name;this.width = width;}public Integer getWidth()
{return width;}}
Response:
var c3 = new Comparator<Painting>() {public int compareTo(Painting p1,
Painting p2){ return p1.getWidth() - p2.getWidth(); }
};andComparator<Painting> c4 = (p1, p2) -> p1.getWidth - p2.getWidth;
Comparator<Painting> c1 = (p1, p2) -> p1.getWidth() -
p2.getWidth();andComparator<Painting> c2 =
Comparator.comparing(Painting::getWidth);
var c3 = new Comparator<Painting>() {public int compareTo(Painting p1,
Painting p2){ return p1.getWidth() - p2.getWidth(); }
};andComparator<Painting> c5 = Comparator.comparing(Painting::getWidth());
Comparator<Painting> c4 = (p1, p2) -> p1.getWidth -
p2.getWidth;andComparator<Painting> c5 =
Comparator.comparing(Painting::getWidth());
Score 1.00 of 1
Question:
Given below are a few statements. Identify the correct ones.1. ORDER BY
and GROUP BY clauses can not co-exist in query.2. HAVING and GROUP BY
can not be present in a query together.3. It's necessary that a GROUP
BY clause is present if the query has a HAVING clause.4. The SELECT
clause must have all the attributes of the GROUP BY clause.
Response:

Options 3 & 4
Options 1 & 2
Score 0.00 of 1
Question:
What would be the output of the following codeclass exception_handling
{ public static void main(String args[]) { try {
System.out.print("A"); throw new NullPointerException ("Hello"); }
catch(ArithmeticException e) { System.out.print("B"); } } }
Response:
A
B
Hello
a ,RunTimeException
Score 1.00 of 1
Question:
Consider the following code:import java.nio.file.*; import java.io.*;
class NIO { public static void main(String [] args)throws IOException {
Path path = Paths.get("data.txt"); File myfile = new
File(path.toString()); myfile.createNewFile(); } }Given that the
current working directory is empty, which one of the given options are
true?
Response:
Compilation fails
Compilation succeeds and a file called "data.txt" will be created in the root
directory
As there is no file called "data.txt" the Paths class' "get()" method will cause a
compile-time error
Compilation succeeds and a file called "data.txt" will be created in the current
working directory
Question Results
Score 1.00 of 1
Question:
Which one is a template for creating different objects
Response:
Array
Class
Interface
Method
Score 1.00 of 1
Question:
Which of the following are not Java modifiers?
Response:
public
private
friendly
protected
Score 1.00 of 1
Question:
Which of the following is a correct implementation of method
overloading?
Response:
void methodA(){} int methodA(){}
void methodA(){} void methodA(int a){}
void methodA(){} int methodB(int a){}
int methodA(){} int methodAA(){}
Score 1.00 of 1
Question:
Which is correct about an instance variable of type String
Response:
It defaults to an empty string.
It defaults to null
It does not have a default value
It will not compile without initializing on the declaration line
Score 1.00 of 1
Question:
How many Primitive Data types are there in Java
Response:
7
8
6
10
Score 1.00 of 1
Question:
Size of primitive int is......bytes
Response:
1 bytes
3 bytes
4 bytes
8 bytes
Score 1.00 of 1
Question:
Which provides runtime environment for java byte code to be executed?
Response:
JDK
JVM
JRE
JAVAC
Score 1.00 of 1
Question:
What is the default return type of the class members in the class?
Response:

default
private
protected
public
Score 1.00 of 1
Question:
What is garbage collection in the context of Java
Response:
Java deletes all unused java files on the system
Memory used by the object with no reference is automatically reclaimed.
The JVM cleans output of Java program with error.
Any unused package in a program automatically gets deleted.
Score 1.00 of 1
Question:
Which of the following declarations does not compile
Response:

double num1, int num2 = 0;


int num1, num2;
int num1, num2 = 0;
int num1 = 0, num2 = 0;
Score 1.00 of 1
Question:
Data type long literals are appended by
Response:
Uppercase L
Lowercase L
Long
Both A and B
Score 1.00 of 1
Question:
Which of the following is true about primitives
Response:
You can call methods on a primitive
You can convert a primitive to a wrapper class object simply by assigning it
You can convert a wrapper class object to a primitive by calling valueOf()
You can store a primitive directly into an ArrayList
Score 1.00 of 1
Question:
Java is a.......Langauage
Response:
weakly typed
strongly typed
moderate typed
None of these
Score 1.00 of 1
Question:
Which statement transfer execution to different parts of your code
based on the value of an expression
Response:
If
Switch
Nested-if
if-else-if
Score 1.00 of 1
Question:
An interface with no fields or methods is known as a ______
Response:
Runnable Interface
Marker Interface
Abstract Interface
CharSequence Interface
Score 1.00 of 1
Question:
Which of the following is not a Java features?
Response:
Dynamic
Architecture Neutral
Use of pointers
Object-oriented
Score 1.00 of 1
Question:
Which one is true about a constructor ?
Response:
A constructor must have the same name as the class it is declared within
A constructor is used to create objects
A constructor may be declared private
All of the above
Score 1.00 of 1
Question:
_____ is used to find and fix bugs in the Java programs.
Response:
JVM
JRE
JDK
JDB
Score 1.00 of 1
Question:
Which of the following are not Java keywords ?
Response:
double
switch
then
while
Score 1.00 of 1
Question:
Given that Student is a class, how many reference variables and objects are created
by the following code?
Student studentName, studentId;
studentName = new Student(); Student stud_class = new Student();
Response:

Three reference variables and two objects are created


Two reference variables and two objects are created
One reference variable and two objects are created.
Three reference variables and three objects are created.
Score 1.00 of 1
Question:
Which of the following option leads to the portability and security of
Java?
Response:

Bytecode is executed by JVM


The applet makes the Java code secure and portable
Use of exception handling
Dynamic binding between objects
Score 1.00 of 1
Question:
What is the return type of the hashCode() method in the Object class?
Response:
Object
int
long
void
Score 1.00 of 1
Question:
Which statement about a valid .java file is true
Response:
It can only contain one class declaration
It can contain one pulic class declaration and one public interface definition
It must define at least one public class
It may define at most one public class
Score 1.00 of 1
Question:
Which variables are created when an object is created with the use of
the keyword 'new' and destroyed when the object is destroyed?
Response:
Local variables
Instance variables
Class Variables
Staic Variables
Score 1.00 of 1
Question:
On which platforms Java runs?
Response:
Windows
Unix
Mac
All of the above
Question Results
Score 1.00 of 1
Question:

Which of the following statements are 'True related to interface?


Response:

Interface doesnt allow to create object .


Multiple inheritence can be possible in interface.
Class can implement only one interface.
Interface can't allow to declare a member variable.
Score 1.00 of 1
Question:
import java.util.*;
class Test {
public static void main(String[] args) {
// insert code here
obj.add("one");
obj.add("two");
obj.add("TWO");
System.out.println(x.poll());
}
}
Which, inserted at // insert code here, will compile?

Response:
List<String> obj = new LinkedList<String> ();
TreeSet<String> obj = new TreeSet<String> ();
HashSet<String> obj = new HashSet<String> ();
Queue<String> obj= new PriorityQueue<String> ();
Score 1.00 of 1
Question:
Which of the following methods of the File class will delete a
directory or file?
Response:
The file class does not allow you to delete a file or directory
remove()
delete()
deleteFile()
Score 1.00 of 1
Question:
class Demo{public static void main(String []args){Path javaHome =
Paths.get("C:/Program Files/Java/jdk1.8.0_25");
System.out.println(javaHome.getNameCount());}}
What will be the output of above code?

Response:
1
2
3
4
Score 1.00 of 1
Question:
A programmer has an algorithm that requires a java.util.List that
provides an efficient implementation of add(0,object), but does NOT
need to support quick random access. What supports these requirements?
Response:
ArrayList
Queue
Linear List
LinkedList
Score 1.00 of 1
Question:
What will happen after the execution of below code?
public class HashSetTest { public static void main(String[] args) {
Set haseSet = new HashSet<>(); haseSet.add("1"); haseSet.add(1);
haseSet.add("null"); haseSet.add(null); System.out.println(haseSet);
}}

Response:

[null, 1, 1, null]
[1,null]
[null,1,null]
[1,1,null]
Score 1.00 of 1
Question:
Predict the output of following Java program:
class Main { public static void main(String args[]) { try {
throw 10; } catch(int e) { System.out.println("Got
the Exception " + e); } }}

Response:
Got the Exception 10
Got the Exception 0
Compilation fails
None of the above
Score 1.00 of 1
Question:
What will be the output of the following Java code?
public class ThreadDemo { public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t.getPriority()); }}

Response:
1
10
5
undefined
Score 1.00 of 1
Question:
Which of the given method must be overridden by a class, after
implementing Comapartor?
Response:
int compare(Object obj);
int compareTo(Object obj);
int compareTo(Object obj1,Object obj2);
int compare(Object obj1,Object obj2);
Score 1.00 of 1
Question:
________ is raised if I do not provide the String array as the argument
to the main method.
Response:
NullPointerException
IllegalAccessException
NoSuchMethodError
None of the above
Score 1.00 of 1
Question:
Which among the following Sets maintains insertion order?
Response:
HashSet
TreeSet
LinkedHashSet
Both B & C
Score 1.00 of 1
Question:
When the JVM runs out of memory, which exception will be thrown?
Response:
MemoryBoundException
OutOfMemoryError
OutOfMemoryException
OutOfRangeException
Score 1.00 of 1
Question:
try { int number = Integer.parseInt("two"); }Which could be used to
create an appropriate catch block?
Response:
ClassCastException
IllegalStateException
NumberFormatException
None of the above is 'True
Score 1.00 of 1
Question:
What will be the output of following program?
public class Foo { public static void main(String[] args) {
try { return; } finally {
System.out.println( "Finally" ); } } }

Response:

Finally
Compilatation fails
No output
Runtime Exception
Score 1.00 of 1
Question:
Which of the following I/O classes helps you in persistence storage of
Objects?
Response:

ObjectOutputStream
DataOutputStream
FileWriter
ObjectWriter
Score 1.00 of 1
Question:
A _______ is used to walk through a collection and can remove elements
from the collection during the iteration.
Response:
Enumeration
Iterator
ArrayList
Vector
Score 1.00 of 1
Question:
Which of these exception is thrown in cases when the file specified for
writing is not found?
Response:
IOException
FileException
FileNotFoundException
FileInputException
Score 0.00 of 1
Question:
What will be the output of below code?
class Test{ public static void main(String[] args) { try { int a[]=
{1, 2, 3, 4}; for (int i = 1; i <= 4; i++) { System.out.println
("a[" + i + "]=" + a[i] + "n"); } } catch (Exception e) {
System.out.println ("error = " + e); } catch
(ArrayIndexOutOfBoundsException e) { System.out.println
("ArrayIndexOutOfBoundsException"); } }}

Response:

Compiler error
Run time error
ArrayIndexOutOfBoundsException
a[1]=2na[2]=3na[3]=4n
Score 1.00 of 1
Question:
Predict the output of the following program:
abstract class demo { public int a; demo() { a = 10; } abstract
public void set(); abstract final public void get();}class Test extends
demo { public void set(int a) { this.a = a; } final public void get()
{ System.out.println("a = " + a); } public static void main(String[]
args) { Test obj = new Test(); obj.set(20); obj.get(); }}

Response:
a = 10
a = 20
compilation error
runtime error
Score 0.00 of 1
Question:
Which of these is not a correct statement?
Response:
Every class containing abstract method must be declared abstract
Abstract class defines only the structure of the class not its implementation
Abstract class can be initiated by new operator
Abstract class can be inherited
Score 1.00 of 1
Question:
What will happen after the execution of below code?
class CreateObject{public static void main(String []args){Set set = new
TreeSet();set.add("Priya");set.add("Ritu");set.add(100);}}

Response:
All elements will be successfully added to set
last element 100 will not be added to set
ClassCastException
IlleagalStateException
Score 1.00 of 1
Question:
What is the output of the following?
import java.util.*;public class Test {public static void main(String[]
args) { Set set = new TreeSet(); set.add("anu"); set.add("anil");
set.add("sunil"); for(Object str:set){ System.out.print(str + " ");}}}

Response:

anil anu sunil


anu anil sunil
Compilation error
Exception
Score 1.00 of 1
Question:
Which of the following is 'False about abstract classes in Java?
Response:
we can use both static and non static variables in abstract classes
Abstract classes can have constructors
A class can be made abstract without any abstract method
A class can inherit from multiple abstract classes
Score 0.00 of 1
Question:
What will be the output of the following Java program?
public class FileDemo { public static void main(String[] args) throws
IOException { InputStream obj = new
FileInputStream("src/inputoutput.txt");
System.out.print(obj.available()); }}
Note: inputoutput.txt is stored in the disk.

Response:
'True
'False
prints number of bytes in file
prints number of characters in the file
Score 1.00 of 1
Question:
Which of these values is returned by read() method is end of file (EOF)
is encountered?
Response:
1
-1
Null
Score 1.00 of 1
Question:
What will be the output?
interface A{ public void method();}class One{ public void method(){
System.out.println("Class One method"); }}class Two extends One
implements A{ public void method(){ System.out.println("Class Two
method"); }}public class Test extends Two{ public static void
main(String[] args){ A a = new Two(); a.method(); }}

Response:
will print Class One method
will print Class Two method
compiles fine but print nothing
Compilation Error
Score 1.00 of 1
Question:
How can you ensure all threads that started from main must end in order
in which they started and also main should end in last?
Response:

join() method
sleep() method
wait() method
run() method
Score 1.00 of 1
Question:
Which collection class allows you to grow or shrink its size and
provides indexed access to its elements, but whose methods are not
synchronized?
Response:
java.util.HashSet
java.util.Vector
java.util.ArrayList
java.util.List
Score 1.00 of 1
Question:
What is the output of the following program?
class Test {public static void main(String[] args) {try
{doMath(5);System.out.print("hi");}finally { System.out.println(" from
finally"); }}public static void doMath(int den) {int num = 7 / den;}}

Response:
hi from finally
hifrom finally
prints hi from finally 2 times
None of the above
Score 1.00 of 1
Question:
What will happen after the execution of below code?
public class HashSetTest { public static void main(String[] args) {
Map map = new HashMap(); map.put(new String("a"), "Audi");
map.put(new String("a"), "Ferrari"); System.out.println(map); }}

Response:

{a=Ferrari}
{a=Audi}
{a=Audi,a=Ferrari}
{a=Ferrari,a=Audi}
compilation fails
Score 0.00 of 1
Question:
What state does Thread enter in when it has been created and started?
Response:
new
runnable
running
waiting
Score 1.00 of 1
Question:
Which of the following statements are 'True related to exception
handling in java?
Response:
UserDefined exception can be created by extending from RunTimeException
class
Throwable is the base class of Error and Exception class
Checked Exception need to be handled either by try and catch block or by using
throws keyword in a code before compilation.
All of the above
Score 1.00 of 1
Question:
Predict the output of following Java program:
class Test extends Exception { } class Main { public static void
main(String args[]) { try { throw new Test(); }
catch(Test t) { System.out.println("Got the Test Exception");
} finally { System.out.println("Inside finally block ");
} }}}

Response:

Got the Test ExceptionInside finally block


Got the Test Exception
Inside finally block
Compilation fails
Score 1.00 of 1
Question:
What will be the output of the following Java program?
public class FileDemo { public static void main(String[] args) {
String obj = "abcdef"; int length = obj.length(); char c[] = new
char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1
= new CharArrayReader(c); CharArrayReader input2 = new
CharArrayReader(c, 0, 3); int i; try { while ((i = input2.read())
!= -1) { System.out.print((char) i); } } catch (IOException e) {
e.printStackTrace(); } }}

Response:

abc
abcd
abcde
Compilation fails
Score 1.00 of 1
Question:
class DemoCmp //line 1{int number;public DemoCmp(int
num){number=num;}//line 2}public class CreateDemo {public static void
main(String []args){TreeSet<DemoCmp>set = new
TreeSet<DemoCmp>();set.add(new Demo(8));set.add(new
Demo(2));set.add(new Demo(3));}}
Which code need to be inserted at line 1 and line 2for successful
execution of above code?

Response:
//line 1class DemoCmp implements Comparable//line
2public int compareTo(Object obj){return number-
obj.number;}
//line 1class DemoCmp implements Comparator//line
2public int compare(Object obj1,Object obj2){return
obj1.number-obj2.number;}
//line 1class DemoCmp implements Comparable//line
2public int compare(Object obj1,Object obj2){return
obj1.number-obj2.number;}
//line 1class DemoCmp implements Comparator//line
2public int compareTo(Object obj){return number-
obj1.number;}
Score 1.00 of 1
Question:
class GenericsDemo{ T data; public GenericsDemo(T data) { this.data =
data; }}
Which of the given statement is 'True about above code?

Response:
GenericsDemo object can be created by passing any type of parameter+B22:C24
GenericsDemo object can be created as given belowGenericsDemo<String>obj
= new GenericsDemo<String>();
GenericsDemo object can be created as given belowGenericsDemo<String>obj
= new GenericsDemo<String>("xyz");
Can not create object of given class
Score 1.00 of 1
Question:
Which of the given statement will ensure that each resource is closed
at the end of statement?
Response:

try with resource


call to close() function on the resource
try with resource and finally
try with catch
Score 1.00 of 1
Question:
Consider the following code:
interface MyInterface {// Method declaration code }
Which of the following code snippet shows the wrong way to declare
Method in interface?

Response:
public abstract boolean isValid();
public boolean isValid();
protected boolean isValid();
boolean isValid();
Score 1.00 of 1
Question:
If a class inheriting an abstract class does not define all of its
function then it will be known as ______.
Response:

Abstract
A simple class
Static class
interface
Score 1.00 of 1
Question:
What will be the output of the following Java code?
class ThreadDemo{ public static void main(String args[])
{ Thread t = Thread.currentThread();
System.out.println(t); } }

Response:
Thread[5,main]
Thread[main,5]
Thread[main,0]
Thread[main,5,main]
Question Results
Score 1.00 of 1
Question:
try { int number = Integer.parseInt("two"); }Which could be used to
create an appropriate catch block?
Response:
ClassCastException
IllegalStateException
NumberFormatException
None of the above is 'True
Score 1.00 of 1
Question:
Which of the following methods of the File class will delete a
directory or file?
Response:
The file class does not allow you to delete a file or directory
remove()
delete()
deleteFile()
Score 1.00 of 1
Question:
class GenericsDemo{ T data; public GenericsDemo(T data) { this.data =
data; }}
Which of the given statement is 'True about above code?

Response:
GenericsDemo object can be created by passing any type of parameter+B22:C24
GenericsDemo object can be created as given belowGenericsDemo<String>obj
= new GenericsDemo<String>();
GenericsDemo object can be created as given belowGenericsDemo<String>obj
= new GenericsDemo<String>("xyz");
Can not create object of given class
Score 1.00 of 1
Question:
When the JVM runs out of memory, which exception will be thrown?
Response:
MemoryBoundException
OutOfMemoryError
OutOfMemoryException
OutOfRangeException
Score 1.00 of 1
Question:
What will be the output of the following Java program?
public class FileDemo { public static void main(String[] args) {
String obj = "abcdef"; int length = obj.length(); char c[] = new
char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1
= new CharArrayReader(c); CharArrayReader input2 = new
CharArrayReader(c, 0, 3); int i; try { while ((i = input2.read())
!= -1) { System.out.print((char) i); } } catch (IOException e) {
e.printStackTrace(); } }}

Response:

abc
abcd
abcde
Compilation fails
Score 1.00 of 1
Question:
Which among the following Sets maintains insertion order?
Response:
HashSet
TreeSet
LinkedHashSet
Both B & C
Score 1.00 of 1
Question:
What will be the output of below code?
class Test{ public static void main(String[] args) { try { int a[]=
{1, 2, 3, 4}; for (int i = 1; i <= 4; i++) { System.out.println
("a[" + i + "]=" + a[i] + "n"); } } catch (Exception e) {
System.out.println ("error = " + e); } catch
(ArrayIndexOutOfBoundsException e) { System.out.println
("ArrayIndexOutOfBoundsException"); } }}

Response:

Compiler error
Run time error
ArrayIndexOutOfBoundsException
a[1]=2na[2]=3na[3]=4n
Score 1.00 of 1
Question:
import java.util.*;
class Test {
public static void main(String[] args) {
// insert code here
obj.add("one");
obj.add("two");
obj.add("TWO");
System.out.println(x.poll());
}
}
Which, inserted at // insert code here, will compile?

Response:
List<String> obj = new LinkedList<String> ();
TreeSet<String> obj = new TreeSet<String> ();
HashSet<String> obj = new HashSet<String> ();
Queue<String> obj= new PriorityQueue<String> ();
Score 1.00 of 1
Question:
A programmer has an algorithm that requires a java.util.List that
provides an efficient implementation of add(0,object), but does NOT
need to support quick random access. What supports these requirements?
Response:
ArrayList
Queue
Linear List
LinkedList
Score 1.00 of 1
Question:
Which of the given statement will ensure that each resource is closed
at the end of statement?
Response:

try with resource


call to close() function on the resource
try with resource and finally
try with catch
Score 1.00 of 1
Question:
Which collection class allows you to grow or shrink its size and
provides indexed access to its elements, but whose methods are not
synchronized?
Response:
java.util.HashSet
java.util.Vector
java.util.ArrayList
java.util.List
Score 1.00 of 1
Question:
Which of these is not a correct statement?
Response:
Every class containing abstract method must be declared abstract
Abstract class defines only the structure of the class not its implementation
Abstract class can be initiated by new operator
Abstract class can be inherited
Score 1.00 of 1
Question:
Which of the given method must be overridden by a class, after
implementing Comapartor?
Response:
int compare(Object obj);
int compareTo(Object obj);
int compareTo(Object obj1,Object obj2);
int compare(Object obj1,Object obj2);
Score 1.00 of 1
Question:
What will happen after the execution of below code?
public class HashSetTest { public static void main(String[] args) {
Set haseSet = new HashSet<>(); haseSet.add("1"); haseSet.add(1);
haseSet.add("null"); haseSet.add(null); System.out.println(haseSet);
}}

Response:

[null, 1, 1, null]
[1,null]
[null,1,null]
[1,1,null]
Score 1.00 of 1
Question:

Which of the following statements are 'True related to interface?


Response:

Interface doesnt allow to create object .


Multiple inheritence can be possible in interface.
Class can implement only one interface.
Interface can't allow to declare a member variable.
Score 1.00 of 1
Question:
class DemoCmp //line 1{int number;public DemoCmp(int
num){number=num;}//line 2}public class CreateDemo {public static void
main(String []args){TreeSet<DemoCmp>set = new
TreeSet<DemoCmp>();set.add(new Demo(8));set.add(new
Demo(2));set.add(new Demo(3));}}
Which code need to be inserted at line 1 and line 2for successful
execution of above code?

Response:
//line 1class DemoCmp implements Comparable//line
2public int compareTo(Object obj){return number-
obj.number;}
//line 1class DemoCmp implements Comparator//line
2public int compare(Object obj1,Object obj2){return
obj1.number-obj2.number;}
//line 1class DemoCmp implements Comparable//line
2public int compare(Object obj1,Object obj2){return
obj1.number-obj2.number;}
//line 1class DemoCmp implements Comparator//line
2public int compareTo(Object obj){return number-
obj1.number;}
Score 1.00 of 1
Question:
Consider the following code:
interface MyInterface {// Method declaration code }
Which of the following code snippet shows the wrong way to declare
Method in interface?

Response:
public abstract boolean isValid();
public boolean isValid();
protected boolean isValid();
boolean isValid();
Score 1.00 of 1
Question:
What will happen after the execution of below code?
public class HashSetTest { public static void main(String[] args) {
Map map = new HashMap(); map.put(new String("a"), "Audi");
map.put(new String("a"), "Ferrari"); System.out.println(map); }}

Response:

{a=Ferrari}
{a=Audi}
{a=Audi,a=Ferrari}
{a=Ferrari,a=Audi}
compilation fails
Score 1.00 of 1
Question:
Which of the following I/O classes helps you in persistence storage of
Objects?
Response:

ObjectOutputStream
DataOutputStream
FileWriter
ObjectWriter
Score 1.00 of 1
Question:
If a class inheriting an abstract class does not define all of its
function then it will be known as ______.
Response:

Abstract
A simple class
Static class
interface
Score 1.00 of 1
Question:
What is the output of the following program?
class Test {public static void main(String[] args) {try
{doMath(5);System.out.print("hi");}finally { System.out.println(" from
finally"); }}public static void doMath(int den) {int num = 7 / den;}}

Response:

hi from finally
hifrom finally
prints hi from finally 2 times
None of the above
Score 1.00 of 1
Question:
Which of these values is returned by read() method is end of file (EOF)
is encountered?
Response:
1
-1
Null
Score 1.00 of 1
Question:
Predict the output of following Java program:
class Test extends Exception { } class Main { public static void
main(String args[]) { try { throw new Test(); }
catch(Test t) { System.out.println("Got the Test Exception");
} finally { System.out.println("Inside finally block ");
} }}}

Response:

Got the Test ExceptionInside finally block


Got the Test Exception
Inside finally block
Compilation fails
Score 1.00 of 1
Question:
Which of the following statements are 'True related to exception
handling in java?
Response:
UserDefined exception can be created by extending from RunTimeException
class
Throwable is the base class of Error and Exception class
Checked Exception need to be handled either by try and catch block or by using
throws keyword in a code before compilation.
All of the above
Score 1.00 of 1
Question:
How can you ensure all threads that started from main must end in order
in which they started and also main should end in last?
Response:

join() method
sleep() method
wait() method
run() method
Score 1.00 of 1
Question:
What will be the output of following program?
public class Foo { public static void main(String[] args) {
try { return; } finally {
System.out.println( "Finally" ); } } }

Response:

Finally
Compilatation fails
No output
Runtime Exception
Score 1.00 of 1
Question:
What is the output of the following?
import java.util.*;public class Test {public static void main(String[]
args) { Set set = new TreeSet(); set.add("anu"); set.add("anil");
set.add("sunil"); for(Object str:set){ System.out.print(str + " ");}}}

Response:

anil anu sunil


anu anil sunil
Compilation error
Exception
Score 1.00 of 1
Question:
________ is raised if I do not provide the String array as the argument
to the main method.
Response:
NullPointerException
IllegalAccessException
NoSuchMethodError
None of the above
Score 1.00 of 1
Question:
class Demo{public static void main(String []args){Path javaHome =
Paths.get("C:/Program Files/Java/jdk1.8.0_25");
System.out.println(javaHome.getNameCount());}}
What will be the output of above code?

Response:
1
2
3
4
Score 1.00 of 1
Question:
Predict the output of the following program:
abstract class demo { public int a; demo() { a = 10; } abstract
public void set(); abstract final public void get();}class Test extends
demo { public void set(int a) { this.a = a; } final public void get()
{ System.out.println("a = " + a); } public static void main(String[]
args) { Test obj = new Test(); obj.set(20); obj.get(); }}

Response:
a = 10
a = 20
compilation error
runtime error
Score 1.00 of 1
Question:
What will be the output of the following Java code?
public class ThreadDemo { public static void main(String args[]) {
Thread t = Thread.currentThread();
System.out.println(t.getPriority()); }}

Response:
1
10
5
undefined
Score 1.00 of 1
Question:
What will be the output of the following Java program?
public class FileDemo { public static void main(String[] args) throws
IOException { InputStream obj = new
FileInputStream("src/inputoutput.txt");
System.out.print(obj.available()); }}
Note: inputoutput.txt is stored in the disk.

Response:
'True
'False
prints number of bytes in file
prints number of characters in the file
Score 1.00 of 1
Question:
What state does Thread enter in when it has been created and started?
Response:
new
runnable
running
waiting
Score 1.00 of 1
Question:
Which of these exception is thrown in cases when the file specified for
writing is not found?
Response:
IOException
FileException
FileNotFoundException
FileInputException
Score 1.00 of 1
Question:
Predict the output of following Java program:
class Main { public static void main(String args[]) { try {
throw 10; } catch(int e) { System.out.println("Got
the Exception " + e); } }}

Response:
Got the Exception 10
Got the Exception 0
Compilation fails
None of the above
Score 1.00 of 1
Question:
What will be the output of the following Java code?
class ThreadDemo{ public static void main(String args[])
{ Thread t = Thread.currentThread();
System.out.println(t); } }

Response:
Thread[5,main]
Thread[main,5]
Thread[main,0]
Thread[main,5,main]
Score 1.00 of 1
Question:
Which of the following is 'False about abstract classes in Java?
Response:
we can use both static and non static variables in abstract classes
Abstract classes can have constructors
A class can be made abstract without any abstract method
A class can inherit from multiple abstract classes
Score 1.00 of 1
Question:
What will be the output?
interface A{ public void method();}class One{ public void method(){
System.out.println("Class One method"); }}class Two extends One
implements A{ public void method(){ System.out.println("Class Two
method"); }}public class Test extends Two{ public static void
main(String[] args){ A a = new Two(); a.method(); }}

Response:
will print Class One method
will print Class Two method
compiles fine but print nothing
Compilation Error
Score 1.00 of 1
Question:
A _______ is used to walk through a collection and can remove elements
from the collection during the iteration.
Response:
Enumeration
Iterator
ArrayList
Vector
Score 1.00 of 1
Question:
What will happen after the execution of below code?
class CreateObject{public static void main(String []args){Set set = new
TreeSet();set.add("Priya");set.add("Ritu");set.add(100);}}

Response:
All elements will be successfully added to set
last element 100 will not be added to set
ClassCastException
IlleagalStateException
Question Results
Score 1.00 of 1
Question:
Which method can be used to check null on an Optional variable in Java
8
Response:

isPresent()
isNullable()
isPresentable()
isNotNull()
Score 1.00 of 1
Question:
How sorting speed has been improved significantly on multi-core
machines by using -
Response:

Arrays.parallelSort
Arrays.sort
Collection.parallelSort
Arrays.sortParallelly
Score 1.00 of 1
Question:
In java 8, R apply(T t) is a method of-
Response:

Function
Process
Predicate
None
Score 1.00 of 1
Question:
How can we obtain source of objects in java 8?
Response:

Stream stream()
Stream obtain()
Stream obtain Source()
All
Score 1.00 of 1
Question:
A pipeline is a sequence of what operations in java 8
Response:
multi-threading
concurrent
consequent
stream
Score 1.00 of 1
Question:
Which class can be used Instead of System.getCurrentTimeMillis() to get
a date and time in Java 8 -
Response:

Clock
Date
Time
Timer
Score 1.00 of 1
Question:
What is Predicate in Java 8 -
Response:
method
class
Interface
Framework
Score 1.00 of 1
Question:
Lambda expressions are __________ scoped
Response:

Lexically
Semantically
Binary
None
Score 1.00 of 1
Question:
Which package contains Date/Time (JSR 310) API in Java 8 -
Response:
java.time
java.util.time
java.timedate
java.util.calendar
Score 1.00 of 1
Question:
Which is aggregate operation in Java 8
Response:
filter
map
forEach
All
Score 1.00 of 1
Question:
Which of these does Streamfilter() operates on
Response:

Predicate
Interface
Class
Methods
Score 1.00 of 1
Question:
In Java 8 Interfaces, methods can be:
Response:
default
abstract
all
none
Score 1.00 of 1
Question:
code before Java 8 essentially used to be -
Response:
Declarative
Imperative
Subjective
None
Score 1.00 of 1
Question:
PermGen space has been replaced with which of these in Java 8 -
Response:
PermSpace
PermSpaceGen
Metaspace
MetaGenSpace
Score 1.00 of 1
Question:
We need to override which Predicate method in Java 8 -
Response:
predict(T t)
predictable(T t)
testable(T t)
test(T t)
Score 1.00 of 1
Question:
Nashorn the new JavaScript engine is an implementation of -
Response:
javax.engine.Engine
javax.script.Engine
javax.javaScript.Engine
javax.script.ScriptEngine
Score 1.00 of 1
Question:
Which of these does Streammap() operates on
Response:
Class
Interface
Predicate
Function
Score 1.00 of 1
Question:
In java 8 Function is ?
Response:
Class
Interface
Lambda Expression
Object
Score 1.00 of 1
Question:
Stream operations in java 8 can be divided into
Response:
Terminal types
Intermediate types
All
None
Score 1.00 of 1
Question:
Which of these represents a process that accepts one argument and
produces a result in Java 8
Response:

Function
Process
Method
JavaFunctions
Score 1.00 of 1
Question:
On which of these does annotations can be used on in Java 8
Response:
Local variables
Super classes
Generic types
All of these
Score 1.00 of 1
Question:
Which is new command line tool for the Nashhorn JavaScript engine in
java 8 -
Response:
jcs
jfs
jjs
jss
Score 1.00 of 1
Question:
void accept(T t) is method of -
Response:

Consumer
Producer
Both
None
Score 1.00 of 1
Question:
What can help us in avoiding NullPointeExceptions and null checks in
java 8 -
Response:

Optional
Required
NotNull
NotRequired
Score 1.00 of 1
Question:
Example of functional interfaces in Java 8 -
Response:
java.util.concurrent.Callable
java.lang.Runnable
All
None
Score 1.00 of 1
Question:
Which of these does forEach() operates on
Response:
Methods
Consumer
Producer
Predicate
Score 1.00 of 1
Question:
The Java 8 API with a sequence of elements which of these supports
sequential and parallel aggregate operations -
Response:
Hadoop
Streams
SequenceProgramming
Big-data
Score 1.00 of 1
Question:
Which of these should be used to show package-level and class-level
dependencies of Class files in Java 8
Response:
dep
ideps
jdep
jdeps
Score 1.00 of 1
Question:
Predicate is in which package in Java 8
Response:
java.util.predicate
java.util.object
java.util.objects
java.util.predict
Question Results
Score 1.00 of 1
Question:
Which Spring Framework module is used to implement cross-cutting
concerns in Spring based-applications?
Response:
ORM
AOP
JDBC
TXM
Score 1.00 of 1
Question:
What is the primary use of the Spring Security module?
Response:

To provide authentication and authorization for web applications


To provide data access and management
To provide Model-View-Controller architecture
To provide aspect-oriented programming functionality
Score 1.00 of 1
Question:
_____ is similar to 'any', but a safer alternative when uncertain about
the type.
Response:
never
similar
unknown
Score 1.00 of 1
Question:
What is the main purpose of the Spring Framework?
Response:
To provide a comprehensive programming and configuration model for Java-
based enterprise applications
To provide a comprehensive programming and configuration model for
JavaScript-based web applications
To provide a comprehensive programming and configuration model for PHP-
based web applications
To provide a comprehensive programming and configuration model for Python-
based web applications
Score 1.00 of 1
Question:
_____ is a return type for when nothing is returned.
Response:

void
any
any[]
unknown
Score 1.00 of 1
Question:
Different ways to inject Spring beans in Spring-based applications?
Response:
Constructor based
Setter based
Field-based
All of the above
Score 1.00 of 1
Question:
What is the scope to create a new instance every time the bean is
requested from the spring container?
Response:
singleton
prototype
request
session
Score 1.00 of 1
Question:
Which is the front controller in Spring MVC?
Response:
FrontDispatcherServlet
DispatcherServlet
FrontControllerService
None of the above
Score 1.00 of 1
Question:
Which interface represents the Spring IOC container?
Response:

ApplicationContext
ApplicationContentFactory
SessionFactory
DispatchServlet
Score 1.00 of 1
Question:
Definitely Typed is_____
Response:
a superset of TypeScript
the official name of TypeScript
a project whose goal is to make types dynamic
a project that provides a central repository of TypeScript definitions for NPM
packages which do not have types
Score 1.00 of 1
Question:
Spring MVC Framework is designed based on which Design Pattern?
Response:

Model-View-Controller (MVC)
Layered pattern
Client-server pattern
None of the above
Score 1.00 of 1
Question:
What is the default scope of the Spring Bean?
Response:

singleton
prototype
request
session
Score 1.00 of 1
Question:
Extension of typescript is?
Response:
.d.tp
d.td
.d.ts
.d.ty
Score 1.00 of 1
Question:
What are Spring stereotype annotations?
Response:
Using Getter and Setter methods
Using Setter and Constructor
Using Getter and Constructor
Using Setter and Factory methods
Score 1.00 of 1
Question:
JdbcTemplate implements the below design pattern?
Response:
Strategy design pattern
Template Design pattern
Singleton design pattern
Decorator design pattern
Score 1.00 of 1
Question:
You can disable implicit variable type assignment by enabling the
compiler option:
Response:

noImplicitAny
noAutoType
Implicit = FALSE
autoTypeAssignment = FALSE
Score 1.00 of 1
Question:
TypeScript supports Object Oriented Programming concepts like classes,
interfaces, inheritance.
Response:

TRUE
False
Can be true or false
None of the above
Score 1.00 of 1
Question:
What is the purpose of the Spring MVC module?
Response:

To provide a web framework for building web applications


To provide a data access framework for accessing databases
To provide a caching framework for caching data
To provide a security framework for securing web applications
Score 1.00 of 1
Question:
What is the purpose of the Spring JDBC module?
Response:

To provide a data access framework for accessing databases


To provide a web framework for building web applications
To provide aspect-oriented programming functionality
To provide caching functionality
Score 1.00 of 1
Question:
TypeScript is a ?
Response:
strongly typed
object oriented
compiled language
All of the above
Score 1.00 of 1
Question:
What is the purpose of the Spring IoC container?
Response:

To manage the lifecycle of beans and their dependencies


To handle the configuration of the application
To provide a caching mechanism for the application
To provide a security mechanism for the application
Score 1.00 of 1
Question:
A ________ in terms of OOP is a blueprint for creating objects.
Response:
method
function
constructor
class
Score 1.00 of 1
Question:
In Spring MVC web applications, all the HTTP requests first come to
which component?
Response:

DispatcherServlet
Controller
HandlerMapper
None of the above
Score 1.00 of 1
Question:
Are singleton beans thread-safe?
Response:
Yes
No
Score 1.00 of 1
Question:
What is the purpose of the Spring MVC module?
Response:

To provide a web framework for building web applications


To provide a data access framework for accessing databases
To provide a caching framework for caching data
To provide a security framework for securing web applications
Score 1.00 of 1
Question:
Different ways to configure Spring-based applications?
Response:
XML based configuration
Java-based configuration
Annotation based configuration
All of the above
Score 1.00 of 1
Question:
What is the type of the parameter: 'function ex(param1?: string){}'?
Response:
string
string | undefined
string | null
unknown
Score 1.00 of 1
Question:
In spring MVC, DispatcherServlet consults ____________ to map the
logical view name with the actual view implementation
Response:

ViewResolver
Handler Mapper
Controller
Model
Score 1.00 of 1
Question:
Definitely Typed is_____
Response:
a superset of TypeScript
the official name of TypeScript
a project whose goal is to make types dynamic
a project that provides a central repository of TypeScript definitions for NPM
packages which do not have types
Question Results
Score 1.00 of 1
Question:
Select the correct statement to create ResultSet interface Object:
Response:
PreparedStatement stmt =
connection.prepareStatement(String sql);ResultSet rs =
new ResultSet();
PreparedStatement stmt =
connection.prepareStatement(String sql);ResultSet rs =
stmt.executeQuery();
PreparedStatement stmt = new PrepareStatement(String
sql);ResultSet rs = stmt.executeQuery();
PreparedStatement stmt = new
PrepareStatement();ResultSet rs =
stmt.executeQuery(String sql);
Score 1.00 of 1
Question:
Which of the given is the correct implementation of Test suites?
Response:
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith
@Suite.SuiteClasses({ TestCalAdd.class,
TestCalSubtract.class,
TestCalMultiply.class, TestCalDivide.class })
public class CalSuite {

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({ TestCalAdd.class,
TestCalSubtract.class,
TestCalMultiply.class, TestCalDivide.class })
public class CalSuite {

}
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@Run(Suite.class)
@Suite.SuiteClasses({ TestCalAdd.class,
TestCalSubtract.class,
TestCalMultiply.class, TestCalDivide.class })
public class CalSuite {
// the class remains completely empty,
// being used only as a holder for the above
annotations
}

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@Suite.SuiteClasses({ TestCalAdd.class,
TestCalSubtract.class,
TestCalMultiply.class, TestCalDivide.class })
public class CalSuite {
// the class remains completely empty,
// being used only as a holder for the above
annotations
}

Score 1.00 of 1
Question:

Choose the correct statements about parameterized test:


Response:

It allows to run the same test with different parameters


It can be specified as : @RunWith(Parameterized.class)
To use it, we need to add static method which returns collection of data.
It can be done with @RunWith(Suite.class)
Score 1.00 of 1
Question:

Which of the given options are mock frameworks?


Response:
DynaMock
Jmock
EasyMock
StaticMock
Score 1.00 of 1
Question:
Which of the given method is used to create EasyMock?
Response:
EasyMock.createMock();
EasyMock.createMock(Classname.class);
EasyMock mock = new EasyMock();
EasyMock mock = new EasyMock(Classname.class);
Score 1.00 of 1
Question:
What is the output of the given code?
public class MyClassTest { @Before public void setUp() {
System.out.println("in setUp method"); } @After public void destroy() {
System.out.println("in destroy method"); } @Test public void test1() {
assert'True('True); System.out.println("test case 1 executed"); }}

Response:

in setUp methodtest case 1 executedin destroy method


test case 1 executed
in setUp methodin destroy method
Compilation fails
Score 1.00 of 1
Question:
Which of the following keyword is used with Data Control Language (DCL)
statements?
Response:
SELECT
INSERT
DELETE
GRANT
Score 1.00 of 1
Question:
Which of the SQL statements is correct?
Response:
SELECT Username AND Password FROM Users
SELECT Username, Password FROM Users
SELECT Username, Password WHERE Username = 'user1'
SELECT Username, Password FROM Users Username = 'user1'
Score 1.00 of 1
Question:
Which of the SQL statements is correct?
Response:
DELETE FROM employeeWHERE first_name = 'Sneha', salary >= 40000;
DELETE FROM employeeWHERE first_name = 'Sneha'AND salary >= 40000;
DELETE employeeWHERE first_name = 'Sneha'AND salary >= 40000;
DELETE employeeWHERE first_name = 'Sneha', salary >= 40000;
Score 1.00 of 1
Question:
Select the correct statement to create PreparedStatement interface
Object:
Response:

PreparedStatement stmt = connection.prepareStatement(String sql);


PreparedStatement stmt = new prepareStatement(String sql);
PreparedStatement stmt = connection.prepareStatement();
PreparedStatement stmt = new prepareStatement();
Score 1.00 of 1
Question:
Which of the given statement is 'True about org.junit.runners.Suite
class?
Response:

It runs group of test cases


It specifies runner class to run the annotated class
Both of the above
None of the above
Score 1.00 of 1
Question:
What is 'True about Connection Pooling?
Response:
It increase the performance system
It promotes reusability
Connection pool implementation not disconnect the link with the database even
though client close the connection
All of the above
Score 1.00 of 1
Question:
The scenario where you want to take data from user each time
differently, this data you want to pass as an argument to the SQL
query. Which of the following statement you will use to execute such
query?
Response:
Statement
PreparedStatement
CallableStatement
All of the above
Score 1.00 of 1
Question:
Which of the following methods is best suitable for executing a DML
statement?
Response:
executeQuery()
executeUpdate()
execute()
getResultSet()
Score 1.00 of 1
Question:
Which of the following are interfaces in JDBC API?
Response:
DriverManager
PreparedStatement
Connection
ResultSet
Statement
Score 1.00 of 1
Question:
Which of the following code snippet is most appropriate to roll back the transaction
when an
error occurs in the transaction?
Response:
conn.setAutoCommit('False);
// perform transactions
conn.commit();
con.setAutoCommit('True);
conn .rollback() ;

try { conn.setAutoCommit('False); // perform


transactions conn.commit(); con.setAutoCommit('True); } catch (SQLException
e) { conn .rollback() ; }

try {
conn.setAutoCommit('True);
// perform transactions
conn.commit();
con.setAutoCommit('False);
} catch (SQLException e) {
conn .rollback() ;
}

Transaction cannot be rolled back


Score 1.00 of 1
Question:
Which of the following methods of ResultSet interface helps in
retrieving the type of each column in the resultSet?
Response:
getData()
getMetaData()
getType()
getColumnType()
Score 1.00 of 1
Question:
Pick up the valid statement to execute the following sql query:
PreparedStatement pstmt = con.prepareStatement("insert into student
values(?,?)");pstmt.setString(1,"Asha");pstmt.setString(2,"Basha");
Response:
ResutlSet rs = pstmt.executeQuery();
Pstmt.executeQuery();
ResultSet rs = pstmt.executeUpdate();
None of the above
Score 1.00 of 1
Question:
ResultSet rs = stmt.executQuery("SELECT name, rank, serialNo FROM employee");
Which of the following will get the value of 'name' from the above ResultSet rs?

Response:
rs.getString(0)
rs.getString(1)
rs.getString("name")
None of the above
Score 1.00 of 1
Question:
Which driver is called as thin-driver in JDBC?
Response:

Type-4 driver
Type-1 driver
Type-3 driver
Type-2 driver
Score 1.00 of 1
Question:
Select the output of the given code:
public class ForEachExample { public static void main(String[] args) {
List<String> gamesList = new ArrayList<String>();
gamesList.add("Football"); gamesList.add("Cricket");
gamesList.add("Chess"); gamesList.add("Hocky");
gamesList.add("Cricket"); gamesList.add("Chess");
gamesList.add("Football"); gamesList.add("null");
gamesList.add(null); Set<String> set =
gamesList.stream().collect(Collectors.toSet()); set.forEach(game ->
System.out.println(game)); }}

Response:

ChessHockynullCricketnullFootball
ChessHockynullCricketFootball
FootballCricketChessHockyCricketChessFootballnull
FootballCricketChessHockyCricketChessFootballnullnull
Score 1.00 of 1
Question:
What will be the output of the given program?
class Test implements Runnable { public void run() {
System.out.println("Run"); } } class Myclass { public static void
main(String[] args) { Test t = new Test(); t.start();
System.out.println("Main"); } }

Response:
Main Run
Run Main
Compile time error
Depend upon JVM
Score 1.00 of 1
Question:
What will be the output of the given program?
class MyThread extends Thread { @Override public void run() {
System.out.println("child thread"); }}public class ThreadDemo { public
static void main(String args[]) { MyThread thread = new MyThread();
thread.start(); thread.start(); }}

Response:

child thread followed by RuntineException


child threadchild thread
child thread
Compilation fails
Score 1.00 of 1
Question:
Select the correct 3 constants of Thread class:
Response:
public static int MINIMUM_PRIORITYpublic static int
NORMAL_PRIORITYpublic static int MAXIMUM_PRIORITY
public static long MINIMUM_PRIORITYpublic static long
NORMAL_PRIORITYpublic static long MAXIMUM_PRIORITY
public static int MIN_PRIORITYpublic static int
NORM_PRIORITYpublic static int MAX_PRIORITY
public static long MIN_PRIORITYpublic static long
NORM_PRIORITYpublic static long MAX_PRIORITY
Score 1.00 of 1
Question:
What will be the output of the given program?
class Test implements Runnable { public void run() {
System.out.println("Run"); } } class Myclass { public static void
main(String[] args) { Thread t1 = new Thread(); t1.start();
System.out.println("Main"); } }

Response:
Run
Main
Compile time error
Run Main
Score 1.00 of 1
Question:
Select the correct statement to create a thread pool 6of 5 fixed
thread:
Response:
ExecutorService executor = Executors.newThreadPool(5);
ExecutorService executor =
Executors.newFixedThreadPool(5);
ExecutorService executor = new ExecutorService(5);
ExecutorService executor = new ThreadPoll(5);
Score 1.00 of 1
Question:
What are the two types of Streams offered by java 8?
Response:

sequential and parallel


Sequential and random
parallel and random
random and synchronized
Score 1.00 of 1
Question:
What is Optional object used for?
Response:
Optional is used for optional runtime argument
Optional is used for optional spring profile
Optional is used to represent null with absent value
Optional means it
Score 1.00 of 1
Question:
In Java 8 Interfaces, methods can be:
Response:
default
abstract
static
All of the above
Score 1.00 of 1
Question:
Select the correct code snippet to display the output as 30:
Response:
'class Calculator { public static int add(int a, int
b) { return a + b; }}public class MethodRefDemo {
public static void main(String[] args) {
BiFunction<Integer, Integer, Integer> adder =
Calculator::add; int result = adder.apply(10, 20);
System.out.println(result); }}
'class Calculator { public static int add(int a, int
b) { return a + b; }}public class MethodRefDemo {
public static void main(String[] args) {
BiFunction<Integer, Integer, Integer> adder =
Calculator.add(); int result = adder.apply(10, 20);
System.out.println(result); }}
'class Calculator { public static int add(int a, int
b) { return a + b; }}public class MethodRefDemo {
public static void main(String[] args) {
BiFunction<Integer, Integer, Integer> adder =
Calculator::add(); int result = adder.apply(10, 20);
System.out.println(result); }}
class Calculator { public static int add(int a, int b)
{ return a + b; }}public class MethodRefDemo { public
static void main(String[] args) { BiFunction<Integer,
Integer, Integer> adder = Calculator:add(); int
result = adder.apply(10, 20);
System.out.println(result); }}
Score 1.00 of 1
Question:
What will be the order of output of the program?
class Test extends Thread { public void run() {
System.out.println("Run"); } } class Myclass { public static void
main(String[] args) { Test t = new Test(); t.start();
System.out.println("Main"); } }

Response:
Main Run
Run Main
Depend upon Program
Depend upon JVM
Score 1.00 of 1
Question:
What is the output of the given code?
class Employee { int id; String name; public Employee() { } public
Employee(int id, String name) { this.id = id; this.name = name; }
//setters and getters}public class ComparableTest { public static void
main(String[] args) { List<Employee> list = new ArrayList<>();
list.add(new Employee(123, "Sugan")); list.add(new Employee(101,
"Kavita")); list.add(new Employee(132, "Anju")); Comparator<Employee>
comparator = (a, b) -> { return a.getName().compareTo(b.getName());
}; list.sort(comparator); list.forEach(e ->
System.out.println(e.getName())); }}

Response:
SuganKavitaAnju
AnjuKavitaSugan
KavitaSuganAnju
Compilation fails
Score 1.00 of 1
Question:
What is the output of the givne code?
public class ForEachExample { public static void main(String[] args) {
List<String> trainers = new ArrayList<String>();
trainers.add("Soham"); trainers.add("Tina"); trainers.add("Anju");
trainers.add("Kavya"); trainers.add(null); trainers.add("null");
trainers.add("Soham"); trainers.add("Tina"); Set<String> list =
trainers.stream().filter(s ->
s.startsWith("S")).collect(Collectors.toSet());
System.out.println(list); }}

Response:
[Tina,Soham,null]
[Soham,Tina,Soham,Tina]
[Soham, Tina]
Compilation fails
NullPoinerException
Score 1.00 of 1
Question:
Select the correct code to display the message "Good Luck":
Response:
'interface MyLambda { public String test();}public
class LambdasTest { public static void main(String[]
args) { MyLambda my = () -> { return "Good Luck";
}; System.out.println(my.test()); }}
'interface MyLambda { public String test();}public
class LambdasTest { public static void main(String[]
args) { MyLambda my = (String s) -> { return "Good
Luck"; }; System.out.println(my.test()); }}
interface MyLambda { public String test();}public
class LambdasTest { public static void main(String[]
args) { MyLambda my = () -> { return "Good Luck";
} System.out.println(my.test()); }}
interface MyLambda { public String test();}public
class LambdasTest { public static void main(String[]
args) { MyLambda my = () -> { return "Good Luck";
}; my.test(); }}
Score 1.00 of 1
Question:
In java 8, void accept(T t) is a method of:
Response:
Predicate
Supplier
Function
Consumer
Score 1.00 of 1
Question:
In java 8, R apply(T t) is a method of:
Response:

Function
Process
Predicate
Consumer
Score 1.00 of 1
Question:
JUnit is used for _________ in Java Application.
Response:
Integration Testing
Code Review
Unit Testing
Black Box Testing
Score 1.00 of 1
Question:
Which of the given annotation is used to do initialization of some task
before each test run?
Response:
@Test
@After
@BeforeClass
@Before
Score 1.00 of 1
Question:
Which of the given option is correct for adding exception to the test
method given below?
Public void divideByZeroTest(){calobj.divide(15,0);}
Note : calobj is an object of Calculate class which contains divide(int
x,int y) method.

Response:

@Test(expected = ArithmeticException.class)
@Test( ArithmeticException.class)
@Before( ArithmeticException.class)
@Before(expected = ArithmeticException.class)
Score 1.00 of 1
Question:
Consider the following code snippet:
import static org.junit.Assert.assertEquals;import org.junit.Test;class
Calculator { public long add(long number1, long number2) { return
number1 + number2; }}public class CalculatorTest { @Test public void
add() throws Exception { Calculator cal = new Calculator();
assertEqual(4, cal.add(1, 3)); }}
The above code returns compile time error. What change needs to be done
in order to run the test successfully?

Response:
There is no error in the code above
The TestCase class has not been extended hence it not recognized as a Test class
Change the assertEquals method to assert'True(4,cal.add(1,3))
The assertEqual method should be written as assertEquals (4,cal.add(1,3))
Question Results
Score 1.00 of 1
Question:
What will be the value of sum after the while loop? int j=9; int sum =
0; while (j<10) { sum += j ; j++; }
Response:
0
9
10
19
Score 0.00 of 1
Question:
Corrective maintenance activity in code construction comes after ______
activity
Response:

System testing
Problem definition
Coding and debugging
System integration
Score 1.00 of 1
Question:
What will be optimized version of this loop?sum = 0;for (i=1; i<=N;
i++) sum = sum + i * j / k + 10;
Response:
sum = 0;for (i=1; i<=N; i++) sum = sum + i * (j / k) + 10;
sum = 0;m = j / k;for (i=1; i<=N; i++) sum = sum + i * m + 10;
sum = (j / k) + 10;for (i=1; i<=N; i++) sum = sum + i * m + 10;
sum = 0;m = j / k + 10;for (i=1; i<=N; i++) sum = sum + i * m;
Score 0.00 of 1
Question:
Worst case scenario in sorting an array of 10 elements using Bubble
sort would be ___ operations.
Response:
log 10
10
20
100
Score 1.00 of 1
Question:
What type of loop would you use in these cases?i. No. of times to loop
is unknown initiallyii. No. of times to loop is known initiallyiii.
loop body needs to be executed at least once
Response:
i - while, ii - for, iii - for
i - while, ii - while, iii - for
i - while, ii - for, iii - do..while
"for" loop for all
Score 1.00 of 1
Question:
Put these steps of building a program, in a correct sequence.i. Check
the designii. Check the codeiii. Code the programiv. Design the program
Response:
i,ii, iii, iv
ii, iii, iv, i
iv, i,iii, ii
iv, iii, i,ii
Score 0.00 of 1
Question:
It is better to use more number of global variables as they can be
easily accessed from different routines.
Response:
TRUE
FALSE
Score 1.00 of 1
Question:
Which among the following is a good code layout?
Response:

float Calculate_Interest ( double principal, float term_yrs, float rate_of_interest)


float Calculate_Interest ( double principal, float term_yrs, float rate_of_interest)
float Calculate_Interest (double principal,float term_yrs,float rate_of_interest)
float Calculate_Interest ( double p, float yrs, float r)
Score 1.00 of 1
Question:
What's wrong with this loop?i = 0;while (i < 10) {i--;}
Response:
Variable i should be used only for 'for' loops
It's an infinite loop
It should be i = i - 1 rather than i--;
Nothing wrong
Score 0.00 of 1
Question:
Checking for ranges of values (e.g. range of marks deciding the grade)
is possible using 'case switch' statements.
Response:
TRUE
FALSE
Score 1.00 of 1
Question:
How can this loop be further optimized?sum = 0;for (i=1; i<=N; i++) sum
= sum + i;
Response:
sum = 1;for (i=2; i<=N; i++) sum = sum + i;
sum = 0;for (i=1; i<N; i++) sum = sum + i;sum = sum + N;
sum = 0;for (i=0; i<=N; i++) sum = sum + i;
sum = N * (N+1)/2;
Score 1.00 of 1
Question:
What will be 'unswitched loops' version for the following code?for
(i=0; i<empcount; i++) {if (emptype == 'P') sal[i] += sal[i] *
1.25;else sal[i] += sal[i] * 1.10;}
Response:
for (i=0; i<empcount; i++) {sal[i] += sal[i] * 1.10;if (emptype == 'P') sal[i] +=
sal[i] * 1.25;}
sal[0] += sal[0] * 1.10;for (i=1; i<empcount; i++) {if (emptype == 'P') sal[i] +=
sal[i] * 1.25;}
if (emptype == 'P') for (i=0; i<empcount; i++) sal[i] += sal[i] * 1.25;else sal[i]
+= sal[i] * 1.10;}
if (emptype == 'P') for (i=0; i<empcount; i++) sal[i] += sal[i] * 1.25;else for
(i=0; i<empcount; i++) sal[i] += sal[i] * 1.10;}
Score 1.00 of 1
Question:
Data of a program variable is stored in a file to be available even
after program execution. This deals with the concept of:
Response:
Scope of variable
Persistence of variable
Binding time of variable
None of these
Score 1.00 of 1
Question:
Reducing the lines of code in a high-level language program may not
improve the speed of the resulting machine code
Response:

TRUE
FALSE
Score 1.00 of 1
Question:
Which of these data structures can be used for sorting purpose?
Response:
Graph
Linked list
Tree
Circular queue
Score 0.00 of 1
Question:
Which program might run faster?
Response:
for (i=0; i<5; i++) strarr[i] = "NULL";
for (i=0; i<4; i++) strarr[i] = "NULL"; strarr[4] = "NULL";
strarr[0] = "NULL";for (i=1; i<5; i++) strarr[i] = "NULL";
strarr[0] = "NULL";strarr[1] = "NULL";strarr[2] = "NULL";strarr[3] =
"NULL";strarr[4] = "NULL";
Score 1.00 of 1
Question:
How can this following search algorithm improved further?for (i=0;
i<count; i++) { if (a[i] == item) { found=true; } }
Response:
By reducing the value of count variable
By changing the data type of array a
By inserting a 'break' statement after 'found=true' within 'if'
By inserting a 'break' statement after 'found=true' after 'if'
Score 1.00 of 1
Question:
Data types of variables cannot determine
Response:
Type of data that can be stored
Amount of memory a variable occupies
Address where the variable can be stored in memory
The range of data that can be stored
Score 1.00 of 1
Question:
Ideal data type to indicate customer's gender i.e. either Male or
Female is
Response:
Integer
Floating poing number
String array
Character
Score 1.00 of 1
Question:
Which of the following statements would fit in the blank space below in
this searching loop?for (i = 0; i < N; i++){ if (arr[i] == item){ found
= true; ____________ }}
Response:
continue
return
exit
break
Score 1.00 of 1
Question:
What's wrong with following program segment?const int Pi = 3.14;float
area = 0, rad = 5;Pi = 6.28;area = Pi * rad * rad;
Response:
'area' should be declared as 'int'
Value of 'Pi' cannot be changed
'Pi' should be assigned to 3.14 again
Area calculation method is wrong
Score 1.00 of 1
Question:
What is the equivalent 'jammed loop' version for the following code?
for (i=0; i<10; i++) sum1 = sum1 + i; for (i=0; i<20; i++) sum2 = sum2
+ i;
Response:
for (i=0; i<10; i++) { sum1 = sum1 + i; sum2 = sum2 + i;}
for (i=0; i<20; i++) { sum1 = sum1 + i; sum2 = sum2 + i;}
for (i=0; i<10; i++) { sum1 = sum1 + i; sum2 = sum2 + i;} for (i=10; i<20; i++)
{ sum2 = sum2 + i;}
These loops cannot be jammed
Score 0.00 of 1
Question:
The OS maintains a _____ data structure to keep the processes that are
to be executed next in line.
Response:
Linked list
Stack
Graph
Queue
Score 1.00 of 1
Question:
One has to think about efficiency of the program: i. While designing
itii. While constructing it
Response:
Only i.
Only ii.
Both i & ii
Neither i nor ii
Score 0.00 of 1
Question:
What is the output of following program segment?int option = 2;switch
(option) { case 1: printf("One"); case 2: printf("Two"); case 3:
printf("Three"); }
Response:
One
Two
TwoThree
Three
Score 1.00 of 1
Question:
Consider the array defined below:int phoneno[5];Which one of the
following assignment is wrong?
Response:
phoneno[1] = 1111;
phoneno[2] = 2222;
phoneno[2] = -2222;
phoneno[5] = 5555;
Score 1.00 of 1
Question:
Which is the best way to make the loop exit in the middle?
Response:
use goto statement
use break statement
use return statement
use recursion
Score 1.00 of 1
Question:
How many times the loop will get executed?for (j=1; j>10; j++) sum =
sum + i;
Response:

0
1
9
10
Score 1.00 of 1
Question:
Which among the following is an example of a program statement?i.
a=0;ii. a + - b;iii. -b + a = a + b;
Response:

i only
ii only
ii & iii only
All are correct
Score 1.00 of 1
Question:
What will be printed if the value of x=20?if (x>10 AND x<20) print
HIGHelse print LOW
Response:
HIGH
LOW
HIGHLOW
Nothing gets printed
Question Results
Score 0.00 of 1
Question:
Given:
public class Main { float result; public static void main(String[]
args) { result = 5 / 2; System.out.println(result); }}
What will be the output?

Response:
2
2.0
2.5
Compile time error
Score 1.00 of 1
Question:
Analyze the following code and choose the correct answer:
int[] arr = new int[5];arr = new int[6];

Response:
The code has compile errors because the variable arr cannot be changed once it
is assigned.
The code has runtime errors because the variable arr cannot be changed once it
is assigned.
The code can compile and run fine. The second line assigns a new array to arr.
The code has compile errors because we cannot assign a different size array to
arr.
Score 0.00 of 1
Question:
What is 'True about the following code?
enum EnumDemo { A }class Test { enum EnumD { B } void
my_method() { enum EnumC { D } } }

Response:
The code compiles without any error
The code compiles if we remove line number 1
The code compiles if we remove line number 5
None of the above is correct
Score 1.00 of 1
Question:
Which of the following are Object class methods?
Response:
toString()
equals()
hashCode()
All of the above
Score 1.00 of 1
Question:
What will happen when you attempt to compile and run the following
class?
class Base { Base(int var) { System.out.println("Base"); }}class
Derived extends Base { public static void main(String argv[]) {
Derived obj = new Derived(); }}

Response:
Compiles without any problem
Compiles and produces output "Base"
Generates Compile time error
None of the above
Score 1.00 of 1
Question:
public class Demos { public static void main(String[] args)
{ String input = "Hello Welcome"; String pattern =
"\\sHello\\sWelcome\\s"; boolean flag = Pattern.matches(pattern,
input); System.out.println(flag);}}
What will be the result?

Response:
'True
'False
Compilation error
Exception
Score 0.00 of 1
Question:
class Employee{String name;int id;public Employee(String name,int
id){this.name = name;this.id=id;}}public class Manager extends
Employee{public static void main(String []args){Manager mgr = new
Manager();}}What will happen after execution of above code?
Response:
Manager class object will be successfully created
Compile time error as there is no default constructor in class Employee
Manager object will be successfully created after implementing default
constructor in Manager class
Default constructor need to be implemented in both classes for successful
creation of Manager class object
Score 1.00 of 1
Question:
What will be the output of the following code snippet?
String str1 = new String( "hello" );String str2 = "hello"; if
(str1==str2) System.out.println( "Equals"); else
System.out.println( "Not Equal");

Response:
Equal
Not Equal
Compilation error
None of the above
Score 1.00 of 1
Question:
class Shape{final public double calArea(){}}public class Circle extends
Shape{int radius;public Circle(int radius){this.radius = radius;}public
double calArea(){return 3.142*radius*radius;}public static void
main(String []args){Shape obj = new
Circle(5);System.out.println(obj.calArea());}}
What will be the output of above code?

Response:
It will display area of circle with radius 5
no output
compilation error
runtime Exception
Score 1.00 of 1
Question:
Which of the following statements are 'True?
Response:
No arg constructor is allways supplied by the Compiler
Constructors cannot be overloaded
Constructors cannot have return type.
Constructors can be static
Score 1.00 of 1
Question:
What will be the output after compiling and running following code?
public class Test{ public static void main(String[] args){
int a=5 , b=6, c=7; System.out.println("Value is "+ b + c);
System.out.println(a + b + c); System.out.println("String "
+ (b+c)); }}

Response:

Value is 67 18 String 13
Value is 13 18 String 13
Value is 13 18 String
Compilation fails
Score 1.00 of 1
Question:
What is the output of the given code?
public class Test {
public static void main(String args[]) {
final int i;
i = 20;
System.out.println(i);
}
}

Response:

20
compile time error
runtime error
0
Score 1.00 of 1
Question:
Given :
public class Test {
public static void main(String args[]) {
int x = 12;
while (x <10) {
x--;
}
System.out.print(x); //line 7
}
}

What is the result?


Response:
10
12
Line 7 will never be reached.
0
Score 1.00 of 1
Question:
Given :
public class Test { public static void main(String args[]) { for (int
i = 0; i <= 10; i++) { if (i > 6) break; }
System.out.println(i); }}
What is the result?

Response:
6
7
10
Compile time error
Score 1.00 of 1
Question:
What all gets printed when the following code is compiled and run?
public class test { public static void main(String args[]) {
for(int i = 0; i <2; i++) { for(int j = 2; j>= 0; j--) {
if(i == j) break; System.out.println("i=" + i + " j="+j);
} } }}
1. i=0 j=0 2. i=0 j=1 3. i=0 j=2 4. i=1 j=0 5. i=1 j=1 6. i=1 j=2

Response:
'1,3,5
'2,4,6
'1,2,5
'3,2,6
Score 1.00 of 1
Question:
What is the output of the given code?
class SuperClass {
int b = 10;
}

class SubClass extends SuperClass {


int b = 20;
}
public class MainTest {
public static void main(String[] args) {
SuperClass object = new SubClass();
System.out.println(object.b);
}
}

Response:

10
20
Compilation fails
0
Score 1.00 of 1
Question:
Given the following code fragment: XXXX choice ; // variable choice is
declared and initialized here switch( choice ) { case 100 :
System.out.println("One hundred");break ; case 20 :
System.out.println("Twenty");break ; case 30 :
System.out.println("Thirty");break ; }Choose the declarations of choice
which will not cause a compiler error:
Response:
byte choice = 100 ;
short choice = 100 ;
int choice = 300 ;
All of the above
Score 1.00 of 1
Question:
Memory deallocation in java is done by:
Response:
Programmer
Operating system
Garbage collector
None of the above
Score 1.00 of 1
Question:
Automatic type conversion in Java takes place when:
Response:
Two type are compatible and size of destination type is shorter than source type.
Two type are compatible and size of destination type is equal of source type.
Two type are compatible and size of destination type is larger than source type.
All of the above
Score 1.00 of 1
Question:
class Shape{Shape(){}}public class Triangle extends Shape{int
base,height;public Triangle(int base,int height){this.base =
base;this.height=height;}public double calArea(){return
o.5*base*height;}public static void main(String []args){Shape ref = new
Triangle(3,4);System.out.println(ref.calArea());}
Which change need to be done in the Shape class for successful
execution of program?

Response:
Declare Shape as abstract class
Remove default constructor from Shape class
declare abstract double calArea() in Shape class
declare abstract double calArea() in Shape class and declare Shape class as
abstract class
Score 1.00 of 1
Question:
Integer var1 = new Integer(2); Integer var2 = new Integer(2); What
happens when you do if (var1==var2)?
Response:
'True
'False
Compilation error
Runtime Exception
Score 1.00 of 1
Question:
public class RegexMatches{ private static String regex = "dog";
private static String input = "The dog says meow. " +"All dogs say
meow."; private static String replace = "cat"; public static void
main(String[] args) { //line no.1 Matcher m =
p.matcher(input); INPUT = m.replaceAll(replace);
System.out.println(input); }}
Which code need to be inserted at line no.1 to execute it successfully?

Response:

Pattern p = Pattern.compile(regex);
Pattern p = Pattern.test(regex);
Pattern p = Pattern.matches(regex);
Pattern p = new Pattern(regex);
Score 1.00 of 1
Question:
Which of the given LocalDate class method is used to obtain current
date?
Response:

now()
parse()
format()
newInstance()
Score 1.00 of 1
Question:
Which one of the following is a valid statement?
Response:
'char[] c = new char();
'char[] c = new char[5];
char[] c = new char(4);
char[] c = new char[];
Score 1.00 of 1
Question:
This always will points to:
Response:

current class object


super class object
sub class object
All of the above
Score 1.00 of 1
Question:
The Scanner class is found in ______ package.
Response:
java.lang
java.util
java.io
None of the above
Score 1.00 of 1
Question:
Which of the given syntax is correct to display date-time with the time
zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00
Europe/Paris? (Assume the zone is Asia/kolkata.)
Response:
ZonedDateTime objt =
ZonedDateTime.of(LocalDateTime.now(),
ZoneId.of("Asia/Kolkata"));
LocalDate date =
LocalDate.now(ZoneId.of("Asia/Kolkata"));
ZonedDateTime time = new
ZonedDateTime("Asia/Kolkata");
ZonedDateTime time = new
ZonedDateTime.of("Asia/Kolkata");
Score 1.00 of 1
Question:
What is the output of the given code?
class A { final void m1() { System.out.println("m1 called"); }}class B
extends A { public void m2() { m1(); System.out.println("m2 called");
}}public class Main { public static void main(String[] args) { B b =
new B(); b.m1(); b.m2(); }}

Response:
m1 calledm2 called
m1 calledm1 calledm2 called
Compilation fails
Runtime error
Score 1.00 of 1
Question:
State 'True or 'False:You can't use a Java keyword as an identifier.
Response:

'True
'False
Score 1.00 of 1
Question:
When access modifier is omitted from the definition of the member of a
class. The member has _________ access.
Response:

default
public
private
protected
Score 1.00 of 1
Question:
Consider the following code:
interface Greek { } class Alpha implements Greek { } class Beta extends
Alpha {} class Delta extends Beta { public static void main(
String[] args ) { Beta obj = new Beta(); // insert code
here } }
Which of the following code snippet when inserted individual at the
commented line (// insert code here), will cause a
java.lang.ClassCastException?

Response:
Greek objGrk = (Beta)(Alpha)obj;
Alpha objAlpha = obj;
Greek objGrk = (Alpha)obj;
Beta objBeta = (Beta)(Alpha)obj;
Greek objGrk = (Delta)obj;
Score 1.00 of 1
Question:
What will be the output after compiling and running following code?
public class Test{ public static void main(String args[]){
int x =5; x *= 3 + 7; System.out.println(x); }}

Response:
22
50
10
Compilation fails
Score 1.00 of 1
Question:
State 'True or 'False:We can use this in static methods.
Response:
'True
'False
Score 1.00 of 1
Question:
public class test {
static void methodA(short s) {
System.out.println("methodA(short) called");
}
static void methodA(int i) {
System.out.println("methodA(int) called");
}
static void methodB(float f) {
System.out.println("methodB(float) called");
}
static void methodB(double d) {
System.out.println("methodB(double) called");
}

public static void main(String args[]) {


methodA(5);
methodB(5.2);
}
}

Response:
methodA(short) called methodB(float) called
methodA(int) called methodB(double) called
methodA(int) called methodB(float) called
Compilation fails
Score 1.00 of 1
Question:
The concept of multiple inheritance is implemented in Java by:I.
Extending two or more classes.II. Extending one class and implementing
one or more interfaces.III. Implementing two or more interfaces.
Response:
Only (II)
(I) and (II)
(II) and (III)
Only (I)
Only (III)
Score 1.00 of 1
Question:
Given:
public class Demo { //Line 1public static void main (String[] args) {
//Line 2byte var1 = 127; //Line 3byte var2 = 126; //Line 4 byte
result = var1 + var2; //Line 5}}
Which statement is 'True?

Response:
Compilation succeeds and d takes the value 253.
Line 5 contains an error that prevents compilation.
Line 5 throws an exception indicating "Out of range"
Line 3 and 4 contain errors that prevent compilation.
Score 1.00 of 1
Question:
What will be the result of compiling and running the given code?
class SuperClass { int b = 10; private SuperClass() { this.b = 7; }
int f() { return b; }}class SubClass extends SuperClass { int
b;}public class MainTest { public static void main(String[] args) {
SuperClass a = new SubClass(); System.out.println(a.f()); }}

Response:

Compilation Fails
Prints 0
Prints 10
Prints 7
Score 1.00 of 1
Question:
class Demo{}public class SubDemo extends Demo{public static void
main(String []args){Demo obj = new SubDemo();System.out.println(obj
instanceof Demo);}}
What will be the output of above code?

Response:
False
True
Demo
SubDemo
Score 1.00 of 1
Question:
What is the Regular Expression Matching Zero or More Specific
Characters?
Response:
\
$
*
^
Score 1.00 of 1
Question:
Which of the following are features of Java Programming Language?
Response:
Robust
Multithreaded
Interpreted
All of the above
Question Results
Score 1.00 of 1
Question:
Which of the following creates a List of 3 visible items and multiple
selections abled?
Response:
new List(false, 3)
new List(3, true)
new List(true, 3)
new List(3, false)
Score 1.00 of 1
Question:
What does the expression float a = 35 / 0 return?
Response:
0
Not a Number
Infinity
Run time exception
Score 1.00 of 1
Question:
Which of the following is a valid syntax to synchronize the HashMap?
Response:
Map m = hashMap.synchronizeMap();
HashMap map =hashMap.synchronizeMap();
Map m1 = Collections.synchronizedMap(hashMap);
Map m2 = Collection.synchronizeMap(hashMap);
Score 1.00 of 1
Question:
What is the default encoding for an OutputStreamWriter?
Response:
UTF-8
Default encoding of the host platform
UTF-12
None of the above
Score 1.00 of 1
Question:
What will be the output of the following program? public class Test {
public static void main(String[] args) { int count = 1; while (count <= 15) { System.out.println(count
% 2 == 1 ? "***" : "+++++"); ++count; } // end while } // end main }
Response:
15 times ***
15 times +++++
8 times *** and 7 times +++++
Both will print only once
Score 1.00 of 1
Question:
Which of the following is a valid long literal?
Response:
ABH8097
L990023
904423
0xnf029L
Score 1.00 of 1
Question:
Which option is false about the final keyword?
Response:
A final method cannot be overridden in its subclasses.
A final class cannot be extended.
A final class cannot extend other classes.
A final method can be inherited.
Score 1.00 of 1
Question:
What is the result of the following program? public static synchronized
void main(String[] args) throws InterruptedException { Thread f = new
Thread(); f.start(); System.out.print("A"); f.wait(1000);
System.out.print("B"); }
Response:
It prints A and B with a 1000 seconds delay between them
It only prints A and exits
It only prints B and exits
A will be printed, and then an exception is thrown.
Score 1.00 of 1
Question:
Which of the following is a valid declaration of a char?
Response:

char ch = '\utea';
char ca = 'tea';
char cr = \u0223;
char cc = '\itea';
Score 1.00 of 1
Question:
In character stream I/O, a single read/write operation performs _____
Response:

Two bytes read/write at a time.


Eight bytes read/write at a time.
One byte read/write at a time.
Five bytes read/ write at a time.
Score 1.00 of 1
Question:
The \u0021 article referred to as a
Response:

Unicode escape sequence


Octal escape
Hexadecimal
Line feed
Score 1.00 of 1
Question:
int values[ ] = {1,2,3,4,5,6,7,8,9,10}; for(int i=0;i< Y; ++i)
System.out.println(values[i]); Find the value of value[i]?
Response:
10
11
15
None of the above
Score 1.00 of 1
Question:
What will be the output of the following program? public class Test2 {
public static void main(String[] args) { StringBuffer s1 = new
StringBuffer("Complete"); s1.setCharAt(1,'i'); s1.setCharAt(7,'d'); System.out.println(s1); } }
Response:
Complete
Iomplede
Cimpletd
Coipletd
Score 1.00 of 1
Question:
Which of the given methods are of Object class?
Response:
notify(), wait( long msecs ), and synchronized()
wait( long msecs ), interrupt(), and notifyAll()
notify(), notifyAll(), and wait()
sleep( long msecs ), wait(), and notify()
Score 1.00 of 1
Question:
What will be the output of the following program? public class MyFirst {
public static void main(String[] args) { MyFirst obj = new MyFirst(n); } static int a = 10; static int
n; int b = 5; int c; public MyFirst(int m) { System.out.println(a + ", " + b + ", " + c + ", " + n + ", " +
m); } // Instance Block { b = 30; n = 20; } // Static Block static { a = 60; } }
Response:
10, 5, 0, 20, 0
10, 30, 20
60, 5, 0, 20
60, 30, 0, 20, 0
Score 1.00 of 1
Question:
What will be the output of the following program? abstract class MyFirstClass
{ abstract num (int a, int b) { } }
Response:
No error
Method is not defined properly
Constructor is not defined properly
Extra parentheses
Score 1.00 of 1
Question:
What should be the execution order, if a class has a method, static block, instance
block, and constructor, as shown below? public class First_C {
public void myMethod() { System.out.println("Method"); }
{ System.out.println(" Instance Block"); }
public void First_C() { System.out.println("Constructor "); } static { System.out.println("static
block"); } public static void main(String[] args) { First_C c = new
First_C(); c.First_C(); c.myMethod(); } }
Response:
Instance block, method, static block, and constructor
Method, constructor, instance block, and static block
Static block, method, instance block, and constructor
Static block, instance block, constructor, and method
Score 1.00 of 1
Question:
Which of the following code segment would execute the stored procedure
"getPassword()" located in a database server?
Response:
CallableStatement cs =
connection.prepareCall("{call.getPassword()}");cs.executeQuery();
CallabledStatement callable = conn.prepareCall("{call
getPassword()}");callable.executeUpdate();
CallableStatement cab = con.prepareCall("{call
getPassword()}");cab.executeQuery();
Callablestatement cstate = connect.prepareCall("{call
getpassword()}");cstate.executeQuery();
Score 1.00 of 1
Question:
Which of the following for loop declaration is not valid?
Response:

for ( int i = 99; i >= 0; i / 9 )


for ( int i = 7; i <= 77; i += 7 )
for ( int i = 20; i >= 2; - -i )
for ( int i = 2; i <= 20; i = 2* i )
Score 1.00 of 1
Question:
Evaluate the following Java expression, if x=3, y=5, and z=10: ++z + y
- y + z + x++
Response:
24
23
20
25

You might also like