Skip to content
Home
About
About Us
Our Services
Software Development
Technology Up-Skill Programs
Java Job Placement Program
Data Science / Data Analyst / Ai Job / Placement Program
IT Staffing
Gallery
Employers
Job Seekers
3000 Technical Interview Questions
120+ Advanced Java Interview Questions and Answers
Artificial Intelligence (AI) Interview Questions and Answers
Top 100 AWS Interview Questions and Answers
Business Intelligence Interview Questions and Answers
Top C# Interview Questions and Answers
120+ Core Java Interview Questions and Answers
Top 100 Programming / Coding Interview Questions and Answers
Top 100 Cyber Security Interview Questions and Answers
Top 100 Data Analyst Interview Questions and Answers
Top 100+ Data Science Interview Questions and Answers
Top Deep Learning Interview Questions And Answers
Top 100+ DOCKER Interview Questions And Answers
Top 100+ Excel Interview Questions and Answers
Express.js Interview Questions & Answers
100 Full Stack Interview Questions and Answers
Top 80 GitHub Interview Questions And Answers
Top 100 Hibernate Interview Questions And Answers
Top Informatica Interview Questions and Answers
Top 50+ JavaScript Interview Questions and Answers
Top 80+ Jenkins Interview Questions and Answers
Top JUnit Interview Questions And Answers
Top 100 Machine Learning Interview Questions and Answers
MEAN Stack Interview Questions and Answers
MERN Stack Interview Questions and Answers
Microservices Interview Questions & Answers
Top 80+ MongoDB Interview Questions and Answers
Top NLP Interview Questions And Answers
Advanced PHP Interview Questions and Answers
PL/SQL Interview Questions & Answers
Top Power BI Interview Questions and Answers
Top 100 Python Interview Questions and Answers
Top 100 PyTorch Interview Questions And Answers
REST Interview Questions & Answers
Top 100 R Programming Interview Questions & Answers
SaaS Interview Questions and Answers
Top 50+ SAS Interview Questions and Answers
Top Software Testing Interview Questions and Answers
Top 50+ Spring Boot Interview Question and Answers
Top 60 Scala Interview Questions And Answers
Top 40 SOAP Interview Questions and Answers
SQL Interview Questions and Answers
Top 50+ TensorFlow Interview Questions and Answers
Tableau Interview Questions and Answers
Job Seeker Resources
Java Test
Free Java SE 21 Certification Practice Tests
Java SE 17 Certification Preparation Test
Free Java Test SE 11 Certification
Free 30 Minute Java Test
5 Minute JAVA Test
AWS Test
AWS Data Engineer Associate Certification Exam
AWS Certified Data Analytics Certification Test
Java and AWS free tests and Quiz
30 Minute AWS Test
5 Minute AWS Test
Microsoft Test
Microsoft Power BI Data Analyst
Microsoft Azure Data Scientist Associate Certification Test
Tableau Test
Tableau Desktop Specialist
Tableau Certified Data Analyst
Free snowflake snowpro core certification tests
Free Databricks certified Data Analyst Test
Azure Data Engineer Associate Certification
Inspirational Videos
Latest Jobs
FAQ
Articles
Home
About
About Us
Our Services
Software Development
Technology Up-Skill Programs
Java Job Placement Program
Data Science / Data Analyst / Ai Job / Placement Program
IT Staffing
Gallery
Employers
Job Seekers
3000 Technical Interview Questions
120+ Advanced Java Interview Questions and Answers
Artificial Intelligence (AI) Interview Questions and Answers
Top 100 AWS Interview Questions and Answers
Business Intelligence Interview Questions and Answers
Top C# Interview Questions and Answers
120+ Core Java Interview Questions and Answers
Top 100 Programming / Coding Interview Questions and Answers
Top 100 Cyber Security Interview Questions and Answers
Top 100 Data Analyst Interview Questions and Answers
Top 100+ Data Science Interview Questions and Answers
Top Deep Learning Interview Questions And Answers
Top 100+ DOCKER Interview Questions And Answers
Top 100+ Excel Interview Questions and Answers
Express.js Interview Questions & Answers
100 Full Stack Interview Questions and Answers
Top 80 GitHub Interview Questions And Answers
Top 100 Hibernate Interview Questions And Answers
Top Informatica Interview Questions and Answers
Top 50+ JavaScript Interview Questions and Answers
Top 80+ Jenkins Interview Questions and Answers
Top JUnit Interview Questions And Answers
Top 100 Machine Learning Interview Questions and Answers
MEAN Stack Interview Questions and Answers
MERN Stack Interview Questions and Answers
Microservices Interview Questions & Answers
Top 80+ MongoDB Interview Questions and Answers
Top NLP Interview Questions And Answers
Advanced PHP Interview Questions and Answers
PL/SQL Interview Questions & Answers
Top Power BI Interview Questions and Answers
Top 100 Python Interview Questions and Answers
Top 100 PyTorch Interview Questions And Answers
REST Interview Questions & Answers
Top 100 R Programming Interview Questions & Answers
SaaS Interview Questions and Answers
Top 50+ SAS Interview Questions and Answers
Top Software Testing Interview Questions and Answers
Top 50+ Spring Boot Interview Question and Answers
Top 60 Scala Interview Questions And Answers
Top 40 SOAP Interview Questions and Answers
SQL Interview Questions and Answers
Top 50+ TensorFlow Interview Questions and Answers
Tableau Interview Questions and Answers
Job Seeker Resources
Java Test
Free Java SE 21 Certification Practice Tests
Java SE 17 Certification Preparation Test
Free Java Test SE 11 Certification
Free 30 Minute Java Test
5 Minute JAVA Test
AWS Test
AWS Data Engineer Associate Certification Exam
AWS Certified Data Analytics Certification Test
Java and AWS free tests and Quiz
30 Minute AWS Test
5 Minute AWS Test
Microsoft Test
Microsoft Power BI Data Analyst
Microsoft Azure Data Scientist Associate Certification Test
Tableau Test
Tableau Desktop Specialist
Tableau Certified Data Analyst
Free snowflake snowpro core certification tests
Free Databricks certified Data Analyst Test
Azure Data Engineer Associate Certification
Inspirational Videos
Latest Jobs
FAQ
Articles
Java Standard Test 14 – 2025
Welcome to your Standard Test 14 - 2025
Name
Email
Phone
Q1. Given:
//in file Movable.java
package p1;
public interface Movable {
int location = 0;
void move(int by);
public void moveBack(int by);
}
//in file Donkey.java
package p2;
import p1.Movable;
public class Donkey implements Movable{
int location = 200;
public void move(int by) {
location = location+by;
}
public void moveBack(int by) {
location = location-by;
}
}
//in file TestClass.java
package px;
import p1.Movable;
import p2.Donkey;
public class TestClass {
public static void main(String[] args) {
Movable m = new Donkey();
m.move(10);
m.moveBack(20);
System.out.println(m.location);
}
}
Identify the correct statement(s).
Select 1 option(s):
Donkey.java will not compile.
TestClass.java will not compile.
Movable.java will not compile.
It will print 190 when TestClass is run.
It will print 0 when TestClass is run.
None
Q2. Identify correct statements about virtual threads.
Select 1 option(s):
The Executors.newWorkStealingPool() method is used to improve virtual thread performance by reusing threads in a thread pool.
A virtual thread is a daemon thread by default but it can be made non-daemon by calling setDaemon(false) on it.
A benefit of virtual threads is that they honor thread prority better than a platform threads.
A virtual thread can be created by creating an instance of VirtualThread, just like Thread.
Virtual threads run faster than platform threads.
None
Q3. Given:
public class Movie{
private String title;
private String genre;
public Movie(String title, String genre){
this.title = title;
this.genre = genre;
}
//accessors not shown
}
and
Stream sm = Stream.of( new Movie("a1", "a"),
new Movie("a2", "a"),
new Movie("b1", "b"), new Movie("c1", null));
Which of the following code fragments will get the number of movies that do not belong to any genre (i.e. where genre is null)?
Select 1 option(s):
int count = sm.collect(Collectors.groupingBy( movie ->
Optional.ofNullable(movie.getGenre()))).get(null).size();
int count = sm.collect( Collectors.groupingBy(movie ->
Optional.ofNullable(movie.getGenre()))).get(Optional.empty()).size();
int count = sm.collect(Collectors.groupingBy(Movie::getGenre)).get(null).size();
int count = sm.collect( Collectors.groupingBy(movie ->
movie.getGenre())).get(Optional.empty()).size();
int count = sm.collect(Collectors.groupingBy(Movie::getGenre))
.get(Optional.empty()).size();
None
Q4. What is the most likely output of the following code:
var list = List.of("X", "Y");
var result = list.parallelStream().reduce(
list.parallelStream().reduce((a, b)->a+b).get(),
(i, j)->i+j, String::concat
);
System.out.println(result);
Select 1 option(s):
A StackOverflowError at runtime.
An java.lang.IllegalStateException saying "stream has already been operated upon or closed"
XYXXYY
XYXY
XXYY
None
Q5. Given that your module named foo.bar contains the following two source files: src/foo.bar/f/b/Baz1.java and src/foo.bar/f/c/Caz1.java.
Which of the following options can be used to compile this module?
(Assume that all directory paths are relative to the current directory.)
Select 1 option(s):
None
Q6. What will happen on running the following program?
Select 1 option(s):
It will print Getting DB and jdbc://derby://localhost:1527//mydb without throwing an exception.
It will throw a NullpointerException at Runtime.
It will print jdbc://derby://localhost:1527//mydb but will NOT print Getting DB.
It will print Getting DB and then throw a NullPointerException.
It will print nothing.
None
Q7. What can be inserted into the following code at //1 so that it will print "Oldboy"?
//imports not shown
class Movie{
static enum Genre {DRAMA, THRILLER, HORROR, ACTION };
private Genre genre;
private String name;
Movie(String name, Genre genre){
this.name = name; this.genre = genre;
}
//accessors not shown
}
public class FilteringStuff {
public static void main(String[] args) {
List movies = Arrays.asList(
new Movie("On the Waterfront", Movie.Genre.DRAMA),
new Movie("Psycho", Movie.Genre.THRILLER),
new Movie("Oldboy", Movie.Genre.THRILLER),
new Movie("Shining", Movie.Genre.HORROR)
);
Predicate horror = mov->mov.getGenre() == Movie.Genre.THRILLER;
Predicate name = mov->mov.getName().startsWith("O");
//1 INSERT CODE HERE
.forEach(mov->System.out.println(mov.getName()));
}
}
Select 1 option(s):
movies.stream().filter(horror, name)
movies.filter({horror, name})
movies.stream().filter({horror, name})
movies.stream().filter(horror).filter(name)
movies.filter(horror).filter(name)
None
Q8. What will be the result of compiling and running the following code?
class Base{
public short getValue(){ return 1; } //1
}
class Base2 extends Base{
public byte getValue(){ return 2; } //2
}
public class TestClass{
public static void main(String[] args){
Base b = new Base2();
System.out.println(b.getValue()); //3
}
}
Select 1 option(s):
It will print 1
It will print 2.
Compile time error at //1
Compile time error at //2
Compile time error at //3
None
Q9. Given:
public class TestClass
{
public static void main(String[] args) throws IOException {
final Reader reader = new FileReader("aaa.a"); //1
try(reader){
reader.read(); //2
}finally{
reader.read(); //3
}
reader.read(); //4
}
}
Assuming that the fle named aaa.a does not exist, what will be the outcome?
Select 1 option(s):
An exception will be thrown at line marked //1.
An exception will be thrown at line marked //2.
An exception will be thrown at line marked //3.
An exception will be thrown at line marked //4.
It will fail to compile.
None
Q10. What will be the result of attempting to compile and run the following program?
class TestClass{
public static void main(String args[]){
var i = 0;
for (i=1 ; i<5 ; i++) continue; //(1)
for (i=0 ; ; i++) break; //(2)
for ( ; i<5?false:true ; ); //(3)
}
}
Select 1 option(s):
The code will compile without error and will terminate without problem when run.
The code will fail to compile, since the continue can't be used this way.
The code will fail to compile, since the break can't be used this way.
The code will fail to compile, since the for statement in line 2 is invalid.
The code will compile without error but will never terminate.
None
Q11. Given:
record Student(int id, String... subjects){
int rank;
public int getRank(){
return rank;
}
}
public class TestClass{
public static void main(String[] args) {
Student s = new Student(123, new String[]{"math", "science"});
System.out.println(s);
}
}
Which change(s) will enable the code to compile?
Select 1 option(s):
Replace record with void.
replace record with class.
Make the rank variable private.
Make the rank variable static.
Change int rank; to int rank = 0; and add a setter method for rank.
Change the type of subjects from String... to String[].
None
Q12. Given:
DoubleStream ds = DoubleStream.of(1.0, 2.0, 3.0);
//INSERT CODE HERE
ds.map(doubleF.apply(5.0)).forEach(System.out::println);
Which of the following statements can be inserted in the above code?
Select 1 option(s):
DoubleFunction< IntUnaryOperator > doubleF = m->n->(int)m+n;
DoubleFunction< DoubleUnaryOperator > doubleF = m->n->m+n;
DoubleFunction< Double > doubleF = m->n->m+n;
DoubleFunction doubleF = m->n->m*1.0/n;
None
Q13. What will be the output of the following code snippet?
int a = 1;
int[] ia = new int[10];
int b = ia[a];
int c = b + a;
System.out.println(b = c);
Select 1 option(s):
0
1
2
true
false
None
Q14. A java source file contains the following code:
interface I {
int getI(int a, int b);
}
interface J{
int getJ(int a, int b, int c);
}
abstract class MyIJ implements J , I { }
class MyI{
int getI(int x, int y){ return x+y; }
}
interface K extends J{
int getJ(int a, int b, int c, int d);
}
Identify the correct statements:
Select 1 option(s):
It will fail to compile because of MyIJ
It will fail to compile because of MyIJ and K
It will fail to compile because of K
It will fail to compile because of MyI and K
It will fail to compile because of MyIJ, K, and MyI
It will compile without any error.
None
Q15. What would be the result of attempting to compile and run the following program?
class TestClass{
static TestClass ref;
String[] arguments;
public static void main(String args[]){
ref = new TestClass();
ref.func(args);
}
public void func(String[] args){
ref.arguments = args;
}
}
Select 1 option(s):
The program will fail to compile, since the static method main is trying to call the non-static method func.
The program will fail to compile, since the non-static method func cannot access the static member variable ref.
The program will fail to compile, since the argument args passed to the static method main cannot be passed on to the non-static method func.
The program will fail to compile, since method func is trying to assign to the non-static member variable 'arguments' through the static member variable ref.
The program will compile and run successfully.
None
Q16. What will the following program print?
class Test{
public static void main(String args[]){
int i=0, j=0;
X1: for(i = 0; i < 3; i++){
X2: for(j = 3; j > 0; j--){
if(i < j) continue X1;
else break X2;
}
}
System.out.println(i+" "+j);
}
}
Select 1 option(s):
0 3
0 2
3 0
3 3
2 2
None
Q17. What will the following code print when run?
public class TestClass {
public static void main(String[] args) throws Exception {
var sa = new String[]{"a", "b", "c"};
for(String s : sa){
if("b".equals(s)) continue;
System.out.println(s);
if("b".equals(s)) break;
System.out.println(s+" again");
}
}
}
Select 1 option(s):
a
a again
c
c again
a
a again
b
a
a again
b
b again
c
c again
None
Q18. What will be the output of the following program?
class Test
{
static int i1, i2, i3;
public static void main(String[] args)
{
try
{
test(i1 = 1, oops(i2=2), i3 = 3);
} catch (Exception e)
{
System.out.println(i1+" "+i2+" "+i3);
}
}
static int oops(int i) throws Exception
{
throw new Exception("oops");
}
static int test(int a, int b, int c) {
return a + b + c;
}
}
Select 1 option(s):
1 0 0
1 2 0
1 2 3
0 0 0
It will not compile.
None
Q19. Given the following declarations, identify which statements will return true:
Integer i1 = 1;
Integer i2 = new Integer(1);
int i3 = 1;
Byte b1 = 1;
Long g1 = 1L;
Double d = 1.0;
Select 2 option(s):
i1 == i2
i1 == i3
i1 == b1
i1.equals(i2)
i1.equals(g1)
i1.equals(b1)
d > 1L
Q20. You have a file named customers.dat in c:\company\records directory. You want to copy all the lines in this file to another file named clients.dat in the same directory and you have the following code to do it:
public static void writeData() {
Path p1 = Paths.get("c:\\company\\records\\customers.dat");
//LINE 20 - INSERT CODE HERE
try (
var br = new BufferedReader(new FileReader(p1.toFile()));
var bw = new BufferedWriter(new FileWriter(p2.toFile()))) {
String line = null;
while ((line = br.readLine()) != null) {
bw.write(line);
bw.newLine();
}
}catch(Exception e){
e.printStackTrace();
}
}
Which of the following options can be inserted independent of each other at //LINE 20 to make it work?
Assume that the current directory for the program when it runs is c:\code.
Select 2 option(s):
Path p2 = p1.resolveSibling("\\clients.dat");
Path p2 = p1.resolveSibling("clients.dat");
Path p2 = p1.relativize("clients.dat");
Path p2 = Paths.get("c:", p1.subpath(0, 2).toString(), "clients.dat");
Path p2 = Paths.get("c:", p1.subpath(1, 2).toString(), "clients.dat");
Q21. What will the following code print when run?
public class TestClass {
public static void m1() throws Exception{
throw new Exception("Exception from m1");
}
public static void m2() throws Exception{
try{
m1();
}catch(Exception e){
//Can't do much about this exception so rethrow it
throw e;
}finally{
throw new RuntimeException("Exception from finally");
}
}
public static void main(String[] args) {
try{
m2();
}catch(Exception e){
Throwable[] ta = e.getSuppressed();
for(Throwable t : ta) {
System.out.println(t.getMessage());
}
}
}
}
Select 1 option(s):
It will print Exception from m1
It will print Exception from finally
It will not print any thing.
It will print a stack trace for a NullPointerException.
None
Q22. Consider following classes:
//In File Other.java
package other;
public class Other { public static String hello = "Hello"; }
//In File Test.java
package testPackage;
import other.*;
class Test{
public static void main(String[] args){
String hello = "Hello", lo = "lo";
System.out.print((testPackage.Other.hello == hello) + " "); //line 1
System.out.print((other.Other.hello == hello) + " "); //line 2
System.out.print((hello == ("Hel"+"lo")) + " "); //line 3
System.out.print((hello == ("Hel"+lo)) + " "); //line 4
System.out.println(hello == ("Hel"+lo).intern()); //line 5
}
}
class Other { static String hello = "Hello"; }
What will be the output of running class Test?
Select 1 option(s):
false false true false true
false true true false true
true true true true true
true true true false true
None of the above.
None
Q23. Given:
Instant now = Instant.now();
Instant now2 = //INSERT CODE HERE
System.out.println(now2);
Which of the following options can be inserted in the above code without causing any compilation or runtime errors?
Select 1 option(s):
now.truncatedTo(ChronoUnit.DAYS);
now.truncatedTo(Period.DAYS);
now.truncatedTo(TemporalUnit.DAYS);
Period.ofDays(now);
now.withMonth(10);
None
Q24. Consider the code shown below:
public class TestClass{
public static int switchTest(int k){
var j = 1;
switch(k){
case 1: j++;
case 2: j++;
case 3: j++;
case 4: j++;
case 5: j++;
default : j++;
}
return j + k;
}
public static void main(String[] args){
System.out.println( switchTest(4) );
}
}
What will it print when compiled and run?
Select 1 option(s):
5
6
7
8
9
It will not compile.
None
Q25. What will the following class print ?
class Test{
public static void main(String[] args){
int[][] a = { { 00, 01 }, { 10, 11 } };
int i = 99;
try {
a[val()][i = 1]++;
} catch (Exception e) {
System.out.println( i+", "+a[1][1]);
}
}
static int val() throws Exception {
throw new Exception("unimplemented");
}
}
Select 1 option(s):
99 , 11
1 , 11
1 and an unknown value.
99 and an unknown value.
It will throw an exception at Run time.
None
Q26. Given:
class Course{
private String id;
private String name;
public Course(String id, String name){
this.id = id; this.name = name;
}
//accessors not shows
}
What will the following code print?
List cList = Arrays.asList(
new Course("803", "OCAJP 7"),
new Course("808", "OCAJP 8"),
new Course("809", "OCPJP 8")
);
cList.stream().filter(c->c.getName().indexOf("8")>-1)
.map(c->c.getId())
.collect(Collectors.joining("1Z0-"));
cList.stream().forEach(c->System.out.println(c.getId()));
Select 1 option(s):
803
808
809
803
1Z0-808
1Z0-809
1Z0-808
1Z0-809
It will throw an exception at run time.
It will not compile.
None
Q27. Given:
class StaticTest{
void m1(){
StaticTest.m2(); // 1
m4(); // 2
StaticTest.m3(); // 3
}
static void m2(){ } // 4
void m3(){
m1(); // 5
m2(); // 6
StaticTest.m1(); // 7
}
static void m4(){ }
}
Which of the lines will fail to compile?
Select 2 option(s):
1
2
3
4
5
6
7
Q28. Identify correct statements about the following code:
List list1 = List.of("A", "B");
List list2 = List.copyOf(list1);
list1.add("C"); //1
list2.add("D"); //2
System.out.println(list1+" "+list2);
Select 1 option(s):
It will print [A, B] [A, B].
It will print [A, B, C] [A, B].
It will print [A, B, C] [A, B, C, D].
It will print [A, B, C, D] [A, B, C, D].
Line marked //1 will cause an exception at run time.
Both the lines marked //1 and //2 will cause an exception at run time.
None
Q29. Given:
public class TestClass {
static int val = 10;
public static int reduce(int val){
class Inner{
public int reduce(int mval){
return mval-val--;
}
}
val--;
return new Inner().reduce(val);
}
public static void main(String[] args) {
reduce(5);
System.out.println(val);
}
}
Select 1 option(s):
5
10
0
9
Compilation failure.
None
Q30. Given:
List strList = Arrays.asList("a", "aa", "aaa");
Function f = x->x.length();
Consumer c = x->System.out.print("Len:"+x+" ");
Predicate p = x->"".equals(x);
strList.forEach( *INSERT CODE HERE* );
What can be inserted in the code above?
Select 1 option(s):
f
c
p
c and p
All of the above.
None of the above.
None
Q31. Consider the following code:
import java.io.*;
public class Test
{
public static void main(String[] args) throws Exception
{
var fw = new FileWriter("text.txt");
// fw.write("hello"); //1
fw.close();
}
}
Which of the following statements are correct?
Select 1 option(s):
It will throw an exception if text.txt does not exist.
It will create text.txt file in the filesystem if it does not exist.
It will not throw an exception if text.txt does not exist and it will not create a file either because nothing is being written to the file.
It will throw an exception if //1 is uncommented and if text.txt does not exist.
It will throw an exception if text.txt already exists.
None
Q32. Which of these expressions will return true?
Select 4 option(s):
Q33. Identify correct statements about the following code:
Select 1 option(s):
It will always print _ab
It will always print either _ab or _ba
It will print either _ab or _a_b
It will print any of the following:
_ab, _ba, _a_b,_b_a
None
Q34. Given:
interface Carnivore{
default int calories(List food){
return food.size()*100;
}
int eat(List foods);
}
class Tiger implements Carnivore{
public int eat(List foods){
System.out.println("Eating "+foods);
return foods.size()*200;
}
}
public class TestClass {
public static int size(List names){
return names.size()*2;
}
public static void process(List names, Carnivore c){
c.eat(names);
}
public static void main(String[] args) {
List fnames = Arrays.asList("a", "b", "c");
Tiger t = new Tiger();
INSERT CODE HERE
}
}
Which of the following options can be inserted independent of each other in the code above without any compilation error?
Select 3 option(s):
process(fnames, t::eat);
process(fnames, t::calories);
process(fnames, TestClass::size);
process(fnames, Carnivore::calories);
process(fnames, Tiger::eat);
Q35. Given:
public class SimpleLoop {
public static void main(String[] args) {
int i=0, j=10;
var count = 0;
while (i<j) {
i++;
j--;
count++;
}
System.out.println(i+" "+j+" "+count);
}
}
What is the result?
Select 1 option(s):
6 4 5
6 5 5
6 5 6
6 4 6
5 5 5
None
Q36. Consider that you are writing a set of classes related to a new Data Transmission Protocol and have created your own exception hierarchy derived from java.lang.Exception as follows:
nthu.trans.ChannelException
+-- enthu.trans.DataFloodingException
+-- enthu.trans.FrameCollisionException
(Both enthu.trans.DataFloodingException and enthu.trans.FrameCollisionException extend ChannelException)
You have a TransSocket class that has the following method:
long connect(String ipAddr) throws ChannelException
Now, you also want to write another "AdvancedTransSocket" class, derived from "TransSocket" which overrides the above mentioned method. Which of the following are valid declaration of the overriding method?
Select 2 option(s):
int connect(String ipAddr) throws DataFloodingException
int connect(String ipAddr) throws ChannelException
long connect(String ipAddr) throws FrameCollisionException
long connect(String ipAddr) throws Exception
long connect(String str)
Q37. A developer has written the following code snippet:
Console c = System.console(); //1
String line = c.readLine("Please enter your name:"); //2
System.out.println("Hello, "+line); //3
Which of the following statements are true about this code if it is run in the background by a scheduler?
Select 1 option(s):
Line //1 will throw IOException
Line //1 will throw NullPointerException.
Line //2 will throw IOException.
Line //2 will throw NullPointerException.
Line //3 will print Hello, null.
None
Q38. Given that the file test.txt is accessible and contains multiple lines, which of the following code fragments will correctly print all the lines from the file?
Select 2 option(s):
Stream< String > lines = Files.find(Paths.get("test.txt"));
lines.forEach(System.out::println);
BufferedReader bfr = new BufferedReader(new FileReader("test.txt"));
System.out.println(bfr.readLines());
Stream< String > lines = Files.list(Paths.get("test.txt"));
lines.forEach(x->System.out.println(x));
Stream< String > lines = Files.lines(Paths.get("test.txt"));
lines.forEach(System.out::println);
Stream< String > lines = Files.lines(Paths.get("test.txt"), Charset.defaultCharset());
lines.forEach(s -> System.out.println(s));
Q39. Which of the following is/are valid instantiations and initializations of a multi dimensional array?
Select 2 option(s):
var array2D = { { 0, 1, 2, 4}, {5, 6}};
int[][][] array3D = {{0, 1}, {2, 3}, {4, 5}};
int[] array2D[] = new int [2] [2];
array2D[0] [0] = 1;
array2D[0] [1] = 2;
array2D[1] [0] = 3;
int[][] array2D = new int[][]{0, 1};
int[] arr = {1, 2};
int[][] arr2 = {arr, {1, 2}, arr};
int[][][] arr3 = {arr2};
int[][] array2D = new int[][] { { 0, 1, 2, 4} {5, 6}};
Q40. Consider the following code:
import java.util.*;
import java.text.*;
public class TestClass
{
public static void main(String[] args) throws Exception
{
double amount = 53000.35;
Locale jp = new Locale("jp", "JP");
//1 create formatter here.
System.out.println( formatter.format(amount) );
}
}
How will you create formatter using a factory at //1 so that the output is in Japanese Currency format?
Select 2 option(s):
NumberFormat formatter = NumberFormat.getCurrencyFormatter(jp);
NumberFormat formatter = new DecimalFormat(jp);
Format formatter = NumberFormat.getCurrencyInstance(jp);
NumberFormat formatter = DecimalFormat.getCurrencyInstance(jp);
NumberFormat formatter = NumberFormat.getInstance(jp);
NumberFormat formatter = new DecimalFormat("#.00");
Q41. Given:
public class TestClass
{
public static void main(String args[])
{
A ab = new B();
A ac = new C();
if( ac instanceof B b1){
b1.b();
if(b1 instanceof C c1){
c1.c();
}
}else{
ac.a();
}
}
}
class A {
void a(){ System.out.println("a"); }
}
class B extends A {
void b(){ System.out.println("b"); }
}
class C extends B {
void c(){ System.out.println("c"); }
}
What will be the output?
Select 1 option(s):
a
b
b
c
b
a
Compilation failure
None
Q42. Which of the following are true regarding overloading of a method?
Select 1 option(s):
An overloading method must have a different parameter list and same return type as that of the overloaded method.
If there is another method with the same name but with a different number of arguments in a class then that method can be called as overloaded.
If there is another method with the same name and same number and type of arguments but with a different return type in a class then that method can be called as overloaded.
An overloaded method means a method with the same name and same number and type of arguments exists in the super class and sub class.
None
Q43. What will the following code print?
IntStream is = IntStream.range(1, 6);
IntStream is2 = is.takeWhile(x-> x%2==0);
is2.forEach(System.out::print);
Select 1 option(s):
2
24
246
It will not print anything.
None
Q44. Given:
String INPUT_FILE = "c:\\temp\\src\\foo.bar\\module-info.java";
Assuming the file exists, which of the following options will print the contents of the file?
Select 2 option(s):
Files.lines(INPUT_FILE).forEach(System.out::println);
Stream< String > lines = Files.lines(Paths.get(INPUT_FILE));
lines.forEach(System.out::println);
Stream< String > lines = Files.readAllLines(Paths.get(INPUT_FILE));
lines.forEach(System.out::println);
List< String > lines = Files.readAllLines(Paths.get(INPUT_FILE));
lines.forEach(System.out::println);
List< String > lines = Files.lines(Paths.get(INPUT_FILE));
lines.forEach(System.out::println);
String[] stra = Files.readLines(Paths.get(INPUT_FILE));
for(String s: stra) System.out.println(s);
Q45. What will the following method print?
public static void iCanDoThis(){
int x = 2;
int y = ~x; //LINE 2
int z = x ^ y; //LINE 3
boolean flag = x z++; //LINE 4
if(flag) {
flag = x > y && x > --z; //LINE 6
}
if(z>-1){ //LINE 8
--z;
} else z++;
System.out.println(flag+" "+z); //LINE 11
}
Select 1 option(s):
true 0
false -1
false 0
true -1
None
Q46. Given the following code:
enum Title
{
MR("Mr. "), MRS("Mrs. "), MS("Ms. ");
private String title;
private Title(String s){
title = s;
}
public String format(String first, String last){
return title+" "+first+" "+last;
}
}
//INSERT CODE HERE
Identify valid code snippets ..
(Assume that Title is accessible wherever required.)
Select 4 option(s):
class TestClass{
void someMethod()
{
System.out.println(Title.format("Rob", "Miller"));
}
}
class TestClass{
void someMethod()
{
System.out.println(Title.MR.format("Rob", "Miller"));
}
}
class TestClass{
void someMethod()
{
System.out.println(MR.format("Rob", "Miller"));
}
}
enum Title2 extends Title
{
DR("Dr. ");
}
class TestClass{
void someMethod()
{
Title.DR dr = new Title.DR("Dr. ");
}
}
enum Title2
{
DR;
private Title t;
}
enum Title2
{
DR;
private Title t = Title.MR;
}
enum Title2
{
DR;
private Title t = Title.MR;
public String format(String s){ return t.format(s, s); };
}
Q47. What will the following code print when compiled and run?
Collection col = new HashSet();
col.add(1);
var list1 = List.of(col); //1
col.add(2); //2
var list2 = List.copyOf(col); //3
System.out.println(list1+", "+list2);
Select 1 option(s):
It will not compile.
Exception at run time at line marked //1.
Exception at run time at line marked //2.
Exception at run time at line marked //3.
[1, 2], [1, 2]
[1], [1, 2]
[[1, 2]], [1, 2]
None
Q48. Which of the following are valid at line 1?
public class X{
//line 1: insert code here.
}
Select 2 option(s):
var s;
String s = 'asdf';
String s = 'a';
String s = this.toString();
String s = asdf;
String s;
var al;
al = new ArrayList<>();
var al = new ArrayList<>();
Q49. Given:
module foo.filter{
requires api;
provides api.Filter with foo.DoNothingFilter;
}
Assuming that api.Filter is an interface with just a single method List filter(List l), which of the following is a valid implementation of foo.DoNothingFilter class?
Select 1 option(s):
package foo;
import api.*;
import java.util.*;
public class DoNothingFilter{
public List< String > filter(List< String > l) { return l; } }
package foo;
import api.*;
import java.util.*;
public class DoNothingFilter implements Filter{
public DoNothingFilter(int a){ }
public List< String > filter(List< String > l) { return l; } }
package foo;
import api.*;
import java.util.*;
public class DoNothingFilter {
public DoNothingFilter(int a){ }
public static Filter provider(){
return new Filter(){
public List< String > filter(List< String > l) { return l; }
};
}
}
package foo;
import api.*;
import java.util.*;
public class DoNothingFilter implements Filter {
public DoNothingFilter(){ }
public static Filter provider(){
return new Filter(){
public List< String > filter(List< String > l) { return l; }
};
}
}
None
Q50. What will the following code print?
enum AccountType{
CHECKING("Checking account"), SAVINGS("Savings account"),
FD("Fixed Deposit");
private String desc;
AccountType(String desc){
this.desc = desc;
}
@Override
public String toString(){
return "Acct type:"+super.toString();
}
}
public class TestClass {
public static void main(String[] args) {
var at = AccountType.valueOf("FD");
System.out.println(at.ordinal()+" "+at);
}
}
Select 1 option(s):
3 Acct type:FD
3 Acct type:Fixed Deposit
3 FD
2 Acct type:FD
2 FD
An exception will be thrown at run time
None
Time's up
Home
About
About Us
Our Services
Software Development
Technology Up-Skill Programs
Java Job Placement Program
Data Science / Data Analyst / Ai Job / Placement Program
IT Staffing
Gallery
Employers
Job Seekers
3000 Technical Interview Questions
120+ Advanced Java Interview Questions and Answers
Artificial Intelligence (AI) Interview Questions and Answers
Top 100 AWS Interview Questions and Answers
Business Intelligence Interview Questions and Answers
Top C# Interview Questions and Answers
120+ Core Java Interview Questions and Answers
Top 100 Programming / Coding Interview Questions and Answers
Top 100 Cyber Security Interview Questions and Answers
Top 100 Data Analyst Interview Questions and Answers
Top 100+ Data Science Interview Questions and Answers
Top Deep Learning Interview Questions And Answers
Top 100+ DOCKER Interview Questions And Answers
Top 100+ Excel Interview Questions and Answers
Express.js Interview Questions & Answers
100 Full Stack Interview Questions and Answers
Top 80 GitHub Interview Questions And Answers
Top 100 Hibernate Interview Questions And Answers
Top Informatica Interview Questions and Answers
Top 50+ JavaScript Interview Questions and Answers
Top 80+ Jenkins Interview Questions and Answers
Top JUnit Interview Questions And Answers
Top 100 Machine Learning Interview Questions and Answers
MEAN Stack Interview Questions and Answers
MERN Stack Interview Questions and Answers
Microservices Interview Questions & Answers
Top 80+ MongoDB Interview Questions and Answers
Top NLP Interview Questions And Answers
Advanced PHP Interview Questions and Answers
PL/SQL Interview Questions & Answers
Top Power BI Interview Questions and Answers
Top 100 Python Interview Questions and Answers
Top 100 PyTorch Interview Questions And Answers
REST Interview Questions & Answers
Top 100 R Programming Interview Questions & Answers
SaaS Interview Questions and Answers
Top 50+ SAS Interview Questions and Answers
Top Software Testing Interview Questions and Answers
Top 50+ Spring Boot Interview Question and Answers
Top 60 Scala Interview Questions And Answers
Top 40 SOAP Interview Questions and Answers
SQL Interview Questions and Answers
Top 50+ TensorFlow Interview Questions and Answers
Tableau Interview Questions and Answers
Job Seeker Resources
Java Test
Free Java SE 21 Certification Practice Tests
Java SE 17 Certification Preparation Test
Free Java Test SE 11 Certification
Free 30 Minute Java Test
5 Minute JAVA Test
AWS Test
AWS Data Engineer Associate Certification Exam
AWS Certified Data Analytics Certification Test
Java and AWS free tests and Quiz
30 Minute AWS Test
5 Minute AWS Test
Microsoft Test
Microsoft Power BI Data Analyst
Microsoft Azure Data Scientist Associate Certification Test
Tableau Test
Tableau Desktop Specialist
Tableau Certified Data Analyst
Free snowflake snowpro core certification tests
Free Databricks certified Data Analyst Test
Azure Data Engineer Associate Certification
Inspirational Videos
Latest Jobs
FAQ
Articles
Home
About
About Us
Our Services
Software Development
Technology Up-Skill Programs
Java Job Placement Program
Data Science / Data Analyst / Ai Job / Placement Program
IT Staffing
Gallery
Employers
Job Seekers
3000 Technical Interview Questions
120+ Advanced Java Interview Questions and Answers
Artificial Intelligence (AI) Interview Questions and Answers
Top 100 AWS Interview Questions and Answers
Business Intelligence Interview Questions and Answers
Top C# Interview Questions and Answers
120+ Core Java Interview Questions and Answers
Top 100 Programming / Coding Interview Questions and Answers
Top 100 Cyber Security Interview Questions and Answers
Top 100 Data Analyst Interview Questions and Answers
Top 100+ Data Science Interview Questions and Answers
Top Deep Learning Interview Questions And Answers
Top 100+ DOCKER Interview Questions And Answers
Top 100+ Excel Interview Questions and Answers
Express.js Interview Questions & Answers
100 Full Stack Interview Questions and Answers
Top 80 GitHub Interview Questions And Answers
Top 100 Hibernate Interview Questions And Answers
Top Informatica Interview Questions and Answers
Top 50+ JavaScript Interview Questions and Answers
Top 80+ Jenkins Interview Questions and Answers
Top JUnit Interview Questions And Answers
Top 100 Machine Learning Interview Questions and Answers
MEAN Stack Interview Questions and Answers
MERN Stack Interview Questions and Answers
Microservices Interview Questions & Answers
Top 80+ MongoDB Interview Questions and Answers
Top NLP Interview Questions And Answers
Advanced PHP Interview Questions and Answers
PL/SQL Interview Questions & Answers
Top Power BI Interview Questions and Answers
Top 100 Python Interview Questions and Answers
Top 100 PyTorch Interview Questions And Answers
REST Interview Questions & Answers
Top 100 R Programming Interview Questions & Answers
SaaS Interview Questions and Answers
Top 50+ SAS Interview Questions and Answers
Top Software Testing Interview Questions and Answers
Top 50+ Spring Boot Interview Question and Answers
Top 60 Scala Interview Questions And Answers
Top 40 SOAP Interview Questions and Answers
SQL Interview Questions and Answers
Top 50+ TensorFlow Interview Questions and Answers
Tableau Interview Questions and Answers
Job Seeker Resources
Java Test
Free Java SE 21 Certification Practice Tests
Java SE 17 Certification Preparation Test
Free Java Test SE 11 Certification
Free 30 Minute Java Test
5 Minute JAVA Test
AWS Test
AWS Data Engineer Associate Certification Exam
AWS Certified Data Analytics Certification Test
Java and AWS free tests and Quiz
30 Minute AWS Test
5 Minute AWS Test
Microsoft Test
Microsoft Power BI Data Analyst
Microsoft Azure Data Scientist Associate Certification Test
Tableau Test
Tableau Desktop Specialist
Tableau Certified Data Analyst
Free snowflake snowpro core certification tests
Free Databricks certified Data Analyst Test
Azure Data Engineer Associate Certification
Inspirational Videos
Latest Jobs
FAQ
Articles
Contact Us
(510) 550 - 7200
39141 Civic Center Dr, Suite 201, Fremont, CA 94539, US