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 8 – 2025
Welcome to your Standard Test 8 - 2025
Name
Email
Phone
Q1. What can be inserted in the following code so that it will print [21, 32, 43] ?
List ls = Arrays.asList(11, 22, 33);
//INSERT CODE HERE
ls.replaceAll(func);
System.out.println(ls);
Select 1 option(s):
Function< Integer > func = x->x+10;
UnaryOperator< Integer > func = x->x+10;
UnaryOperator< Integer, Integer > func = x->x+10;
Consumer< Integer > func = x->x+10;
Operator< Integer > func = x->x+10;
None
Q2. Given:
Stream s1 = Stream.of("1", "2", "3", "4");
Stream s2 = Stream.of("1", "2", "3");
Identify correct statements.
Select 3 option(s):
Q3. What will be printed when the following code is compiled and run?
package trywithresources;
import java.io.IOException;
public class Device implements AutoCloseable{
String header = null;
public void open(){
header = "OPENED";
System.out.println("Device Opened");
}
public String read() throws IOException{
throw new IOException("Unknown");
}
public void writeHeader(String str) throws IOException{
System.out.println("Writing : "+str);
header = str;
}
public void close(){
header = null;
System.out.println("Device closed");
}
public static void testDevice(){
try(Device d = new Device()){
d.open();
d.writeHeader("TEST");
d.close();
}catch(IOException e){
System.out.println("Got Exception");
}
}
public static void main(String[] args) {
Device.testDevice();
}
}
Select 1 option(s):
Device Opened
Device closed
Got Exception
Device Opened
Writing : TEST
Device closed
Device closed
Device Opened
Writing : TEST
Device closed
Got Exception
Device Opened
Writing : TEST
Device closed
Device closed
Got Exception
Device Opened
Writing : TEST
Device closed
Device closed
(an exception stack trace)
None
Q4. What will be the result of attempting to run the following program?
public class StringArrayTest{
public static void main(String args[]){
String[][][] arr = {
{ { "a", "b" , "c"}, { "d", "e", null } },
{ {"x"}, null },{{"y"}},{ { "z","p"}, {}
}
};
System.out.println(arr[0][1][2]);
}
}
Select 1 option(s):
It will throw NullPointerBoundsException.
It will throw ArrayIndexOutOfBoundsException.
It will print null.
It will run without any error but will print nothing.
None of the above.
None
Q5. What will the following code fragment print?
Path p1 = Paths.get("photos/goa");
Path p2 = Paths.get("/index.html");
Path p3 = p1.relativize(p2);
System.out.println(p3);
Select 1 option(s):
..\index.html
\index.html
\photos\index.html
\photos\goa\index.html
java.lang.IllegalArgumentException will be thrown
None
Q6. What will the following code print when run?
import java.nio.file.Path;
import java.nio.file.Paths;
public class PathTest {
public static void main(String[] args) {
var p1 = Paths.get("c:\\code\\java\\PathTest.java");
System.out.println(p1.getName(3).toString());
}
}
Select 1 option(s):
It will throw NullPointerException
It will throw IllegalArgumentException
It will throw InvalidArgumentException
It will throw ArrayIndexOutOfBoundsException
None
Q7. Given:
public record Book(String title, Double price){ }
Consider the following code:
List<List> books = Arrays.asList(
Arrays.asList(
new Book("Windmills of the Gods", 7.0),
new Book("Tell me your dreams",9.0) ),
Arrays.asList(
new Book("There is a hippy on the highway", 5.0),
new Book("Easy come easy go", 5.0)) );
double d = books.stream()
INSERT CODE HERE //1
INSERT CODE HERE //2
.sum();
System.out.println(d);
What can be inserted in the above code so that it will print 26.0?
Select 1 option(s):
.flatMap(bs)
and
.mapToDouble(book.price())
.flatMap(bs.stream())
and
.mapToDouble(book.price())
.flatMap(bs->bs.stream())
and
.map(book->book.price()).toDouble()
.flatMap(bs.stream())
and
.map(book->book.price()).toDouble()
.flatMap(bs->bs.stream())
and
.mapToDouble(book->book.price())
None
Q8. What will the following code print when run?
import java.io.Reader;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class MarkTest {
public static void main(String[] args) {
try (Reader r = new BufferedReader(new FileReader("c:\\temp\\test.txt"))) {
if (r.markSupported()) {
BufferedReader in = (BufferedReader) r;
System.out.print(in.readLine());
in.mark(100);
System.out.print(in.readLine());
System.out.print(in.readLine());
in.reset();
System.out.print(in.readLine());
in.reset();
System.out.println(in.readLine());
}else{
System.out.println("Mark Not Supported");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Assume that the file test.txt contains:
A
B
C
D
E
Select 1 option(s):
Mark Not Supported
ABCB
< exception stack trace >
ABC
< exception stack trace >
ABCBB
ABCBD
None
Q9. What will the following program print when run?
public class ChangeTest {
private int myValue = 0;
public void showOne(int myValue){
myValue = myValue;
}
public void showTwo(int myValue){
this.myValue = myValue;
}
public static void main(String[] args) {
var ct = new ChangeTest();
ct.showTwo(200);
System.out.println(ct.myValue);
ct.showOne(100);
System.out.println(ct.myValue);
}
}
Select 1 option(s):
0 followed by 100.
100 followed by 100.
0 followed by 200.
100 followed by 200.
200 followed by 200.
200 followed by 100
None
Q10. Identify the correct statements regarding the following program?
package trywithresources;
import java.io.IOException;
public class Device implements AutoCloseable{
String header = null;
public Device(String name) throws IOException{
header = name;
if("D2".equals(name)) throw new IOException("Unknown");
System.out.println(header + " Opened");
}
public String read() throws IOException{
return "";
}
public void close(){
System.out.println("Closing device "+header);
throw new RuntimeException("RTE while closing "+header);
}
public static void main(String[] args) throws Exception {
try(Device d1 = new Device("D1");
Device d2 = new Device("D2")){
throw new Exception("test");
}
}
}
Select 1 option(s):
It will end up with an Exception containing message test.
It will end up with a RuntimeException containing message RTE while closing D1
It will end up with an IOException containing message Unknown.
It will end up with a RuntimeException containing message RTE while closing D1 and a suppressed IOException containing message Unknown.
It will end up with an IOException containing message Unknown and a suppressed RuntimeException containing message RTE while closing D1.
None
Q11. Consider the following class...
public class ParamTest {
public static void printSum(int a, int b){
System.out.println("In int "+(a+b));
}
public static void printSum(Integer a, Integer b){
System.out.println("In Integer "+(a+b));
}
public static void printSum(double a, double b){
System.out.println("In double "+(a+b));
}
public static void main(String[] args) {
printSum(1, 2);
}
}
What will be printed?
Select 1 option(s):
In int 3
In Integer 3
In double 3.0
In double 3
It will not compile.
None
Q12. What can be inserted in the following code so that it will print 12?
public class TestClass{
interface Doer{
String doIt(int x, String y);
}
public static void main(String[] args) {
INSERT CODE HERE
System.out.println(d.doIt(2, "12345"));
}
}
Select 2 option(s):
int a; String b;
Doer d = (a, b)->b.substring(0, a);
int a = 0; String b = "";
Doer d = (a, b)->b.substring(0, a);
Doer d = (a, b)->b.substring(0, a);
Doer d = (int a, String b)->b.substring(0, a);
Doer d = a, b->b.substring(0, a);
Q13. What will be the result of compilation and execution of the following code ?
DoubleStream is = DoubleStream.of(0, 2, 4); //1
double sum = is.filter( i->i%2 != 0 ).sum(); //2
System.out.println(sum); //3
Select 1 option(s):
It will print 0.0
It will print 6.0
It will print OptionalDouble[0.0] if line at //2 is replaced with OptionalDouble x = is.sum();
It will not compile.
It will throw an exception at run time.
None
Q14. What will the following program print when compiled and run?
class Game{
public void play() throws Exception{
System.out.println("Playing...");
}
}
public class Soccer extends Game{
public void play(){
System.out.println("Playing Soccer...");
}
public static void main(String[] args){
Game g = new Soccer();
g.play();
}
}
Select 1 option(s):
It will not compile.
It will throw an Exception at runtime.
Playing Soccer...
Playing...
None of these.
None
Q15. Identify correct statements about the modular JDK.
Select 3 option(s):
Modular JDK allows modular as well as non-modular applications to co-exist.
Modular JDK facilitates aggressive API deprecation.
With modular JDK it is possible to assemble and optimize a set of modules and their dependencies into a custom runtime image.
Modular JDK allows a module to export a package only to a specific module as well.
The foundational APIs of the Java SE platform are in java.lang module.
Only a modular application can be packaged as a jimage.
Q16. Given the following class definitions, the expression
(obj instanceof A) && ! (obj instanceof C) && ! (obj instanceof D)
correctly identifies whether the object referred to by obj was created by instantiating class B rather than classes A, C and D?
class A {}
class B extends A {}
class C extends B {}
class D extends C {}
Select 1 option(s):
True
False
None
Q17. What will the following code print when compiled and run?
import java.util.*;
public class TestClass {
public static void main(String[] args) throws Exception {
SequencedCollection sc = new ArrayList(); //1
sc.add(111); //2
System.out.println(sc.get(sc.size())); //3
}
}
Select 1 option(s):
It will not compile because of line //1.
It will throw an exception at run time because of line //1
It will throw an exception at run time because of line //2
It will not compile because of line //3
null.
It will throw an exception at run time because of line //3
None
Q18. What will the following program print when compiled and run?
class Data {
private int x = 0;
private String y = "Y";
public Data(int k){
this.x = k;
}
public Data(String k){
this.y = k;
}
public void showMe(){
System.out.println(x+y);
}
}
public class TestClass {
public static void main(String[] args) throws Exception {
new Data(10).showMe();
new Data("Z").showMe();
}
}
Select 1 option(s):
0Z
10Y
10Y
0Z
It will not compile.
It will throw an exception at run time.
None
Q19. Given:
interface Identifier{
int id();
}
sealed class Person
permits Student //LINE A
{
}
record Student(int id,
String subject)
extends Person //LINE B
implements Identifier //LINE C
{
public static final long serialVersionUID = 1L; //LINE D
private String name = "unknown"; //LINE E
String name(){ return "unknown"; } //LINE F
public int id(){ return id; } //LINE G
}
Which lines will cause compilation issues?
Select 3 option(s):
LINE A
LINE B
LINE C
LINE D
LINE E
LINE F
LINE G
Q20. Consider the following program:
public class TestClass{
public static void main(String[] args) { calculate(2); }
public static void calculate(int x){
String val;
switch(x){
case 2:
default:
val = "def";
}
System.out.println(val);
}
}
What will happen if you try to compile and run the program?
Select 2 option(s):
It will not compile saying that variable val may not have been initialized..
It will compile and print def
As such it will not compile but it will compile if calculate(2); is replaced by calculate(3);
It will compile for any int values in calculate(...);
Q21. What will the following code print?
String s1 = """
a \
b \t
c \s
""";
System.out.println(s1.length()+" "+s1.split("\\n").length);
Select 1 option(s):
11 3
12 3
11 4
10 2
10 3
9 2
None
Q22.What will the following code print when run?
LocalDate d = LocalDate.now();
java.time.format.DateTimeFormatter df = new java.time.format.DateTimeFormat(FormatStyle.LONG);
System.out.println(df.format(d));
Select 1 option(s):
It will print current date in LONG format.
It will print the number of milliseconds since 1 Jan 1970.
It will not compile.
It will throw an exception at runtime.
None
Q23. Given:
class TestClass{
public static void main(String[] args) throws Exception {
List list = new CopyOnWriteArrayList();
ExecutorService es = Executors.newFixedThreadPool(5);
CyclicBarrier cb = new CyclicBarrier(2, ()->System.out.print("All Done"));
IntStream.range(0, 5).forEach(n->es.execute(
()->{
try{
list.add(n);
cb.await();
}catch(InterruptedException|BrokenBarrierException e){
System.out.println("Exception");
}
}
));
es.shutdown();
}
}
What will the above program print?
Select 2 option(s):
It will print "All Done" once.
It will print "All Done" twice.
It will never print "All Done".
It will print "All Done" once and end.
It may print "All Done" once or twice.
The program will not end.
The program will end.
Q24. The following class will print 'index = 2' when compiled and run.
class Test{
public static int[ ] getArray() { return null; }
public static void main(String[] args){
var index = 1;
try{
getArray()[index=2]++;
}
catch (Exception e){ } //empty catch
System.out.println("index = " + index);
}
}
Select 1 option(s):
True
False
None
Q25. What will the following code print?
Duration d = Duration.ofMillis(1100);
System.out.println(d);
d = Duration.ofSeconds(61);
System.out.println(d);
Select 1 option(s):
PT1S
PT1M1S
PT1S1m
PT1M1S
PT1.1S
PT61S
PT1.1S
PT1M1S
None
Q26. What is the result of executing the following fragment of code:
var b1 = false;
var b2 = false;
if (b2 = b1 == false){
System.out.println("true");
} else{
System.out.println("false");
}
Select 1 option(s):
Compile time error.
It will print true
It will print false
Runtime error.
It will print nothing.
None
Q27. Your application was developed and packaged on the Java 8 platform as a jar file. It consists of the following packages:
com.abc.stocks
com.abc.stocks.valuation
com.abc.stocks.analytics
com.abc.bonds
com.abc.bonds.valuation
com.abc.bonds.analytics
com.abc.derivatives
com.abc.derivatives.valuation
com.abc.derivatives.analytics
You are now trying to modularize it into three different modules. Which of the following module descriptions could potentially be valid?
Select 1 option(s):
module com.abc.stocks{
provides com.abc.stocks.analytics;
}
module com.abc.bonds{
provides com.abc.bonds.analytics;
}
module com.abc.derivatives{
provides com.abc.derivatives.analytics;
}
module com.abc.stocks{
exports com.abc.stocks.analytics;
}
module com.abc.bonds{
exports com.abc.bonds.analytics;
}
module com.abc.derivatives{
exports com.abc.derivatives.analytics;
}
module com.abc.stocks{
opens com.abc.stocks.analytics;
}
module com.abc.bonds{
opens com.abc.bonds.analytics;
}
module com.abc.derivatives{
opens com.abc.derivatives.analytics;
}
module com.abc.stocks{
uses com.abc.stocks.valuation;
uses com.abc.stocks.analytics;
}
module com.abc.bonds{
uses com.abc.bonds.valuation;
uses com.abc.bonds.analytics;
}
module com.abc.derivatives{
uses com.abc.derivatives.valuation;
uses com.abc.derivatives.analytics;
}
None
Q28. Given the following exception classes:
class MyException extends Exception{}
class MyException1 extends MyException{}
class MyException2 extends MyException{}
class MyException3 extends MyException2{}
and the following code:
try{
//code that could potentially throw any of the above mentioned exceptions
}
INSERT CODE HERE
Which of the following options can be inserted in the above code?
Select 1 option(s):
catch(MyException|MyException3 e){ }
catch(MyException3 me3){ }
catch(Exception e){ }
catch(MyException2 me2){ }
catch(MyException3 me3){ }
catch(Throwable t){ }
catch(MyException3 me3){ }
catch(MyException|MyException1|MyException2|MyException3 e){ }
None
Q29. Your group has an existing application (reports.jar) that uses a library (analytics.jar) from another group in your company. Both - the application and the library - use a JDBC driver packaged in ojdbc8.jar.
Which of the following options describes the steps that will be required to modularize your application?
Select 1 option(s):
1. Convert analytics.jar and ojdbc8.jar into automatic modules
2. Convert reports.jar into a named module.
3. Add requires clauses for analytics and ojdbc8 in reports.jar in its module-info.
1. Modularize analytics.jar and ojdbc8.jar into modules by adding module-info to these jars.
2. Convert reports.jar into a named module.
3. Add requires clauses for all packages contained in analytics.jar and ojdbc8.jar that are directly referred to by classes in reports.jar in its module-info.
1. Convert reports.jar into a named module.
2. Add requires clauses for analytics and ojdbc8 modules in reports.jar in its module-info.
3. Use analytics.jar and ojdbc8.jar as unnamed modules.
1. Convert ojdbc8.jar into automatic module.
2. Convert analytics.jar into a named module by adding module-info to it. In this module-info, export all packages that are used by reports.jar and add requires clauses for all packages of ojdbc8.jar that are used by analytics.jar.
3. Convert reports.jar into a named module. Add requires clause for analytics module in reports's module-info.
None
Q30. What will be the output of the following program?
public class TestClass{
public static void main(String args[ ] ){
int i = 0 ;
boolean bool1 = true ;
boolean bool2 = false;
boolean bool = false;
bool = ( bool2 & method1(i++) ); //1
bool = ( bool2 && method1(i++) ); //2
bool = ( bool1 | method1(i++) ); //3
bool = ( bool1 || method1(i++) ); //4
System.out.println(i);
}
public static boolean method1(int i){
return i>0 ? true : false;
}
}
Select 1 option(s):
It will print 1.
It will print 2.
It will print 3.
It will print 4.
It will print 0.
None
Q31. Consider the following code:
class Outsider
{
public class Insider{ }
}
public class TestClass
{
public static void main(String[] args)
{
var os = new Outsider();
// 1 insert line here
}
}
Which of the following options can be inserted at //1?
Select 1 option(s):
Insider in = os.new Insider();
os.Insider in = os.new Insider();
Outsider.Insider in = os.new Insider();
Insider in = Outsider.new Insider();
None
Q32. Consider the following code appearing in the same file:
class Data {
private int x = 0, y = 0;
public Data(int x, int y){
this.x = x; this.y = y;
}
}
public class TestClass {
public static void main(String[] args) throws Exception {
Data d = new Data(1, 1);
//add code here
}
}
Which of the following options when applied individually will change the Data object currently referred to by the variable d to contain 2, 2 as values for its data fields?
Select 1 option(s):
Add the following two statements :
d.x = 2;
d.y = 2;
Add the following statement:
d = new Data(2, 2);
Add the following two statements:
d.x += 1;
d.y += 1;
Add the following method to Data class:
public void setValues(int x, int y){
this.x.setInt(x); this.y.setInt(y);
}
Then add the following statement:
d.setValues(2, 2);
Add the following method to Data class:
public void setValues(int x, int y){
this.x = x; this.y = y;
}
Then add the following statement:
d.setValues(2, 2);
None
Q33. What will the following code print when compiled and run?
public class TestClass{
public static int operate(IntUnaryOperator iuo){
return iuo.applyAsInt(5);
}
public static void main(String[] args) {
IntFunction fo = a->b->a-b; //1
int x = operate(fo.apply(20)); //2
System.out.println(x);
}
}
Select 1 option(s):
Compilation error at //1
Compilation error at //2
15
-15
20
Exception at run time
None
Q34. Which of the following interface definitions can use Lambda expressions?
Select 2 option(s):
interface A{
}
interface A{
default void m(){};
}
interface A{
void m(){};
}
interface A{
default void m1(){};
void m2();
}
interface A{
void m1();
void m2();
}
sealed interface A permits B{
void m();
}
non-sealed interface B extends A{ }
Q35. What will the following code print?
SequencedCollection s1 = new ArrayList();
String s = null;
s1.addFirst("a");
s1.add(s); //1
s1.add("b");
s1.remove(s); //2
System.out.println(s1); //3
Select 1 option(s):
A NullPointerException will be thrown at line marked //1.
A NullPointerException will be thrown at line marked //2.
A NullPointerException will be thrown at line marked //3.
[a, b]
[a, null, b]
[]
None
Q36. Which of the following four constructs are valid?
1.
switch(5)
{
default :
}
2.
switch(5)
{
default : break;
}
3.
switch(8);
4.
var x = 0;
switch(x){
}
5.
public int switchTest(byte x){
return switch(x){
default -> 0;
case '1' -> 1;
};
}
Select 1 option(s):
1, 3, 5
1, 2, 3
3, 4
1, 2, 4, 5
All are valid.
None
Q37. What will the following code print when compiled and run?
public class Discounter {
static double percent; //1
int offset = 10, base= 50; //2
public static double calc(double value) {
var coupon, offset, base; //3
if(percent <10){ //4
coupon = 15;
offset = 20;
base = 10;
}
return coupon*offset*base*value/100; //5
}
public static void main(String[] args) {
System.out.println(calc(100));
}
}
Select 1 option(s):
3000
3000.0
compilation error at //3
compilation error at //4
compilation error at //5
Exception at run time.
None
Q38. What will the following code print?
int x = 1;
int y = 2;
int z = x++;
int a = --y;
int b = z--;
b += ++z;
int answ = x>a?y>b?y:b:x>z?x:z;
System.out.println(answ);
Select 1 option(s):
0
1
2
-1
-2
3
None
Q39. What will the following code print when compiled and run?
HashSet keys = new HashSet(List.of("a", "b", "c"));
ArrayList values = new ArrayList(Set.of("1", "2", "3"));
Map m = new HashMap();
int i = 0;
for(var key : keys){
m.put(key, values.get(i++));
}
keys.clear(); //2
values.clear();
System.out.println(m.keySet().size()+" "+m.values().size());
Select 1 option(s):
It will throw an java.lang.UnsupportedOperationException.
0 0
3 3
It will not compile.
None
Q40. Consider the following classes:
class A {
public int getCode(){ return 2;}
}
class AA extends A {
public void doStuff() {
}
}
Given the following two declarations, which of the options will compile?
A a = null;
AA aa = null;
Select 4 option(s):
a = (AA)aa;
a = new AA();
aa = new A();
aa = (AA) a;
aa = a;
((AA)a).doStuff();
Q41. Given:
ArrayList source = new ArrayList();
source.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));
List destination =
Collections.synchronizedList(new ArrayList());
source
.parallelStream() //1
.peek(item->{destination.add(item); }) //2
.forEachOrdered(System.out::print);
System.out.println("");
destination
.stream() //3
.forEach(System.out::print); //4
System.out.println("");
What changes must be made to the above code so that it will consistently print
123456
123456
?
Select 1 option(s):
Replace code at //1 with
.stream()
Replace code at //2 with
.map(item->{destination.add(item); return item; })
Replace code at //3 with
.parallelStream()
Replace code at //4 with
.forEachOrdered(System.out::print);
None
Q42. What will the following code fragment print?
Path p1 = Paths.get("\\personal\\readme.txt");
Path p2 = Paths.get("\\index.html");
Path p3 = p1.relativize(p2);
System.out.println(p3);
Select 1 option(s):
\index.html
\personal\index.html
personal\index.html
..\..\index.html
None
Q43. Identify valid statements.
Select 3 option(s):
Locale myLocale = System.getDefaultLocale();
Locale myLocale = Locale.getDefaultLocale();
Locale myLocale = Locale.getDefault();
Locale myLocale = Locale.US;
Locale myLocale = Locale.getInstance();
Locale myLocale = new Locale("ru", "RU");
Q44. Consider the following code:
public class FileCopier {
public static void copy(String records1, String records2) {
try (
InputStream is = new FileInputStream(records1);
OutputStream os = new FileOutputStream(records2); ) { //1
if(os == null) os = new FileOutputStream("c:\\default.txt"); //2
byte[] buffer = new byte[1024];
int bytesRead = 0;
while ((bytesRead = is.read(buffer)) != -1) { //3
os.write(buffer, 0, bytesRead);
System.out.println("Read and written bytes " + bytesRead);
}
} catch (IOException e) { //4
e.printStackTrace();
}
}
public static void main(String[] args) {
copy("c:\\temp\\test1.txt", "c:\\temp\\test2.txt");
}
}
Assuming appropriate import statements and the existence of both the files, what will happen when the program is compiled and run?
Select 1 option(s):
The program will not compile because the try statement is used incorrectly.
The program will not compile because the catch clause is used incorrectly.
The program will not compile because line //2 is invalid.
It will compile and run without any error or exception.
None
Q45. What will be the result of attempting to compile and run the following program?
public class TestClass{
public static void main(String args[ ] ){
Object a, b, c ;
a = new String("A");
b = new String("B");
c = a;
a = b;
System.out.println(""+c);
}
}
Select 1 option(s):
The program will print java.lang.String@XXX, where XXX is the memory location of the object a.
The program will print A
The program will print B
The program will not compile because the type of a, b, and c is Object.
The program will print java.lang.String@XXX, where XXX is the hash code of the object a.
None
Q46. Given:
int[][] orig = { { 1, 2, 3} , { 4, 5, 6, 7}};
int[][] dup = orig.clone();
int[] copy = dup[0].clone();
System.out.println(orig == dup);
System.out.println(orig.equals(dup));
System.out.println(orig[0] == dup[0]);
System.out.println(dup[0] == copy);
System.out.println(dup[0].equals(copy));
How many times will true be printed?
Select 1 option(s):
0
1
2
3
4
5
None
Q47. What will the following code print when run?
Deque d = new ArrayDeque();
d.add(1);
d.add(2);
d.addFirst(3);
System.out.println(d.pollLast());
System.out.println(d.pollLast());
System.out.println(d.pollLast());
Select 1 option(s):
1
2
3
3
2
1
3
1
2
2
1
3
Exception at run time
It will not compile.
None
Q48. What will the following code fragment print?
Path p1 = Paths.get("c:\\personal\\.\\photos\\..\\readme.txt");
Path p2 = p1.normalize();
System.out.println(p2);
Select 1 option(s):
readme.txt
c:\personal\photos\readme.txt
c:\personal\readme.txt
c:\photos\readme.txt
None
Q49. You have an existing java application that contains the following packages -
com.acme.provisioning.client
com.acme.provisioning.service
com.acme.provisioning.dto
com.acme.provisioning.database
The dependency of classes in these packages is as follows -
Classes in the client package use classes from the service and the dto package.
Classes in the service package use classes from the dto and the database package
Classes in the database package use classes from the dto package.
Classes in the dto package do not use classes from any other package.
You want to modularize the application into three modules, namely, acme.provisioning.client, acme.provisioning.service, and acme.provisioning.dto.
Which of the following would be a valid module-info for the service module?
Select 1 option(s):
module acme.provisioning.service{
exports com.acme.provisioning.service;
exports com.acme.provisioning.database;
requires acme.provisioning.dto;
}
module acme.provisioning.service{
exports com.acme.provisioning.service;
requires acme.provisioning.dto;
}
module acme.provisioning.service{
exports com.acme.provisioning.service;
requires com.acme.provisioning.database;
requires acme.provisioning.dto;
}
Since there are four interdependent packages in the app, it cannot be modularized into three modules.
None
Q50. Given:
class NewException extends Exception {}
class AnotherException extends Exception {}
public class ExceptionTest{
public static void main(String[] args) {
try{
if(args.length == 0) m2(); else m3();
}
*INSERT CODE HERE*
}
public static void m2() throws NewException { throw new NewException(); }
public static void m3() throws AnotherException{ throw new AnotherException(); }
}
Which of the following options can be inserted in the above code to make it compile?
Select 3 option(s):
catch(NewException|Exception ne){ }
catch(Exception|AnotherException ne){ }
catch(NewException|AnotherException ne){ }
catch(NewException ne){ }
catch(AnotherException ne){ }
catch(AnotherException ne){ }
catch(NewException ne){ }
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