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 16 – 2025
Welcome to your Standard Test 16 – 2025
Name
Email
Phone
Q1. What will the following code print when compiled and run?
class ABCD{
int x = 10;
static int y = 20;
}
class MNOP extends ABCD{
int x = 30;
static int y = 40;
}
public class TestClass {
public static void main(String[] args) {
System.out.println(new MNOP().x+", "+new MNOP().y);
}
}
Select 1 option(s):
10, 40
30, 20
10, 20
30, 40
20, 30
Compilation error.
None
Q2. Given:
StringBuilder sb = new StringBuilder("abcdef");
//INSERT CODE HERE
for(int i = 0, k = sb.length(); i<k; i++){
sb.replace(i, i+1, f.apply(sb.charAt(i)));
}
System.out.println(sb);
Which of the following statements can be inserted in the above code?
Select 1 option(s):
Function f = i->i+1;
Function< String > f = i->""+(i+1);
Function f = i->((Character)i).charValue()+1;
Function< Character > f = i->i+1;
Function< Character, String > f = i->""+Character.valueOf((char)(i+1));
Function< String, Character > f = i->new String(i.toString());
None
Q3. What will the following code print?
Stream ss = Stream.of("a", "b", "c");
String str = ss.collect(Collectors.joining(",", "-", "+"));
System.out.println(str);
Select 1 option(s):
-a+,-b+,-c+
a,-+b,-+c
-a,b,c+
It will throw an exception at run time.
None
Q4. Given:
package loops;
public class JustLooping {
private int j;
void showJ(){
while(j<=5){
for(int j=1; j <= 5;){
System.out.print(j+" ");
j++;
}
j++;
}
}
public static void main(String[] args) {
new JustLooping().showJ();
}
}
What is the result?
Select 1 option(s):
It will not compile.
It will print 1 2 3 4 5 five times.
It will print 1 3 5 five times.
It will print 1 2 3 4 5 once.
It will print 1 2 3 4 5 six times.
None
Q5. What will the following code print?
public class BreakTest{
public static void main(String[] args){
int i = 0, j = 5;
lab1 : for( ; ; i++){
for( ; ; --j) if( i >j ) break lab1;
}
System.out.println(" i = "+i+", j = "+j);
}
}
Select 1 option(s):
i = 1, j = -1
i = 1, j = 4
i = 0, j = 4
i = 0, j = -1
It will not compile.
None
Q6. Consider the following code to count objects and save the most recent object:
int i = 0 ;
Object prevObject ;
public void saveObject(List e ){
prevObject = e ;
i++ ;
}
Which of the following calls will work without throwing an exception?
Select 3 option(s):
saveObject( new ArrayList() );
Collection c = new ArrayList(); saveObject( c );
List el = new ArrayList(); saveObject(el);
saveObject(null);
saveObject(0); //The argument is the number zero and not the letter o
Q7. What changes can be done to the following code so that it will compile and run without an exception?
SequencedCollection keys = List.of("a"); //1
keys.add("b"); //2
Map map = Map.of(); //3
int i = 0;
for(var key : keys){
map.put(key, "----");
}
System.out.println(keys+" "+map.size());
Select 1 option(s):
No change is necessary; it will print 2 2.
No change is necessary; it will print 2 1.
Remove //2
Remove //2 and change Map.of() in //3 to new TreeMap().
None
Q8. Given the following contents of module-info.java,
module enthu.finance{
exports com.enthu.Reports to com.enthu.tax;
requires transitive enthu.utils;
}
Select correct statements.
Select 1 option(s):
Which ever module requires enthu.finance, must require enthu.utils as well.
The enthu.finance module requires all modules required by enthu.utils.
The enthu.finance module requires only those modules that are required by enthu.utils but does not require enthu.utils itself.
Only classes from the com.enthu.tax module are allowed to read classes in the com.enthu.Reports package.
The enthu.finance module exports only those classes that are used by the com.enthu.tax module.
This is an invalid module definition because exports-to and requires-transitive clauses cannot be used together.
Only non-sealed classes from com.enthu.Reports are exported.
None
Q9. Given:
public List getList(){
*INSERT CODE HERE*
}
What can be inserted in the above code?
Select 3 option(s):
return new ArrayList< Integer >();
return new ArrayList< Number >();
return new ArrayList< Object >();
return new ArrayList();
return new List< Number >();
Q10. You have been given an array of objects and you need to process this array as follows -
1. Call a method on each object from first to last one by one.
2. Call a method on each object from last to first one by one.
3. Call a method on only those objects at even index (0, 2, 4, 6, etc.)
Which of the following are correct?
Select 1 option(s):
Enhanced for loops can be used for all the three tasks.
Enhanced for loop can be used for only the first task. For the rest, standard for loops can be used.
Standard for loops can be used for tasks 1 and 2 but not 3.
All the tasks can be performed either by using only standard for loops or by using only enhanced for loops.
Neither standard for loops nor enhanced for loops can be used for all three tasks.
None
Q11. Which statement(s) about the following code are correct?
interface House{
public default void lockTheGates(){
System.out.println("Locking House");
}
}
interface Office {
public void lockTheGates();
}
class HomeOffice implements House, Office{ //1
}
public class TestClass {
public static void main(String[] args) {
Office off = new HomeOffice(); //2
off.lockTheGates(); //3
House home = (House) off; //4
home.lockTheGates(); //5
}
}
Select 1 option(s):
Code for class HomeOffice will cause compilation to fail at //1.
Lines at //3 and //5 will cause compilation to fail.
Line at //4 will cause compilation to fail.
There will no compilation error. The code will print Locking House twice.
None
Q12. Consider the following piece of code, which is run in an environment where the default locale is English - US:
Locale.setDefault(new Locale("fr", "CA")); //Set default to French Canada
Locale l = Locale.getDefault();
ResourceBundle rb = ResourceBundle.getBundle("appmessages", l);
String msg = rb.getString("greetings");
System.out.println(msg);
You have created two resource bundles for appmessages, with the following contents:
#In English US resource bundle file
greetings=Hello
#In French CA resource bundle file
greetings=bonjour
What will be the output?
Select 1 option(s):
Hello
bonjour
An exception at run time.
No message will be printed.
None
Q13. What will the following code fragment print when compiled and run?
Locale myloc = new Locale.Builder().setLanguage("hinglish")
.setRegion("IN").build(); //L1
ResourceBundle msgs = ResourceBundle.getBundle("mymsgs", myloc);
Enumeration en = msgs.getKeys();
while(en.hasMoreElements()){
String key = en.nextElement();
String val = msgs.getString(key);
System.out.println(key+"="+val);
}
Assume that only the following two properties files (contents of the file is shown below the name of the file) are accessible to the code.
1. mymsgs_hinglish_US.properties
okLabel=OK
cancelLabel=Cancel
2. mymsgs_hinglish_UK.properties
okLabel=YES
noLabel=NO
Select 1 option(s):
It will not compile due to line L1.
It will not print anything.
okLabel=OK
cancelLabel=Cancel
okLabel=YES
noLabel=NO
It will throw an exception at run time.
None
Q14. Given:
class Item{
private int id;
private String name;
public Item(int id, String name){
this.id = id;
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString(){
return name;
}
}
public class Test {
public static void main(String[] args) {
List l = Arrays.asList(
new Item(1, "Screw"),
new Item(2, "Nail"),
new Item(3, "Bolt")
);
l.stream()
//INSERT CODE HERE
.forEach(System.out::print);
}
}
Which of the following options can be inserted in the above code independent of each other, so that the code will print BoltNailScrew?
Select 2 option(s):
.sorted((a, b)->a.getId().compareTo(b.getId()))
.sorted(Comparator.comparing(a->a.getName())).map((i)->i.getName())
.map((i)->i.getName())
.map((i)->i.getName()).sorted()
Q15. What will happen when the following code is compiled and run?
class AX{
static int[] x = new int[0];
static{
x[0] = 10;
}
public static void main(String[] args){
var ax = new AX();
}
}
Select 1 option(s):
It will throw NullPointerException at runtime.
It will throw ArrayIndexOutOfBoundsException at runtime.
It will throw ExceptionInInitializerError at runtime.
It will not compile.
None
Q16. Which of the following are valid declarations inside an interface independent of each other?
Select 3 option(s):
default void compute();
public void compute();
static void compute(){
System.out.println("computing...");
}
static void compute();
default static void compute(){
System.out.println("computing...");
};
interface I {
sealed class Inner { }
final class IC extends Inner{ }
}
Q17. What will the following code print when run?
public class TestClass{
public static Integer wiggler(Integer x){
Integer y = x + 10;
x++;
System.out.println(x);
return y;
}
public static void main(String[] args){
Integer dataWrapper = Integer.valueOf("5", 16);
Integer value = wiggler(dataWrapper);
System.out.println(dataWrapper+value);
}
}
Select 1 option(s):
5 and 20
6 and 515
6 and 20
6 and 615
It will not compile.
None
Q18. Consider the following code snippet :
public void readData(String fileName) throws Exception {
try(FileReader fr1 = new FileReader(fileName)){
Connection c = getConnection();
//...other valid code
}
}
Given that the call to getConnection method in the above code throws a ClassNotFoundException and that an IOException is thrown while closing fr1, which exception will be received by the caller of readData() method?
Select 1 option(s):
java.lang.Exception
java.lang.ClassNotFoundException
java.io.IOException
java.lang.RuntimeException
None
Q19. Assuming that a valid integer will be passed in the command line as first argument, which statements regarding the following code are correct?
public class TestClass{
public static void main(String args[]){
var x = Integer.parseInt(args[0]);
switch(x){
case x < 5 : System.out.println("BIG"); break;
case x > 5 : System.out.println("SMALL");
default : System.out.println("CORRECT"); break;
}
}
}
Select 1 option(s):
BIG will never be followed by SMALL.
SMALL will never follow anything else.
SMALL will always be followed by CORRECT.
It will not compile.
It will throw an exception at runtime.
None
Q20. Given:
List names = Arrays.asList(1, 2, 3);
How many of the following lines will print exactly 6?
1. System.out.println(names.stream().mapToInt(x->x).sum());
2. System.out.println(names.stream().forEach((sum, x)->sum = sum + x));
3. System.out.println(names.stream().reduce(0, (a, b)->a+b));
4. System.out.println(names.stream().collect(
Collectors.mapping(x->x, Collectors.summarizingInt(x->x))).getSum());
5. System.out.println(names.stream().collect(Collectors.summarizingInt(x->x)).getSum());
Select 1 option(s):
1
2
3
4
5
None
Q21. What will the following code print when compiled and run?
class Test{
public static void main(String args[]){
int c = 0;
A: for(var i = 0; i < 2; i++){
B: for(var j = 0; j < 2; j++){
C: for(var k = 0; k < 3; k++){
c++;
if(k>j) break;
}
}
}
System.out.println(c);
}
}
Select 1 option(s):
7
8
9
10
11
None
Q22. Consider the following method which is called with an argument of 7, d, where d is some double value:
public void method1(int i, double d){
int j = (i*30 - 2)/100;
POINT1 : for(;j<10; j++){
var flag = false;
while(!flag){
if(d > 0.5) break POINT1;
}
}
while(j>0){
System.out.println(j--);
if(j == 4) break POINT1;
}
}
What will it print?
Select 1 option(s):
It will print 1 and 2
It will print 1 to N where N depends on the value passed as an argument to the parameter d.
It will not compile.
It will throw an exception at runtime.
None
Q23. java.util.Locale allows you to do which of the following?
Select 2 option(s):
Provide country specific formatting for fonts.
Provide country and language specific formatting for HTML pages.
Provide country and language specific formatting for Dates.
Provide country specific formatting for Currencies.
Provide country and language specific formatting for properties files.
Q24. Which of the following method(s) of java.util.stream.Stream interface is/are used for reduction?
Select 2 option(s):
collect
count
distinct
findAny
findFirst
Q25. What will the following code print?
Map map1 = new HashMap();
map1.put("a", 1);
map1.put("b", 1);
map1.merge("b", 1, (i1, i2)->i1+i2);
map1.merge("c", 3, (i1, i2)->i1+i2);
System.out.println(map1);
Select 1 option(s):
{a=1, b=2, c=3}
{a=1, b=1, c=3}
{a=1, b=2}
A NullPointerException will be thrown at run time.
None
Q26. What will the following code print if file test1.txt exists but test2.txt doesn't exist?
public class FileCopier {
public static void copy1(Path p1, Path p2) throws Exception {
Files.copy(p1, p2, StandardCopyOption.COPY_ATTRIBUTES,
StandardCopyOption.REPLACE_EXISTING);
}
public static void main(String[] args) throws Exception {
Path p1 = Paths.get("c:\\temp\\test1.txt");
Path p2 = Paths.get("c:\\temp\\test2.txt");
copy1(p1, p2);
if(Files.isSameFile(p1, p2)){
System.out.println("file copied");
}else{
System.out.println("unable to copy file");
}
}
}
Select 1 option(s):
An exception at run time if either of p1 or p1 is a symbolic link.
It will print file copied and test2.txt will contains the same data as test1.txt.
It will print file copied but test2.txt will NOT contain the same data as test1.txt.
It will print unable to copy file but test2.txt will contain the same data as test1.txt.
It will print unable to copy file and test2.txt will not be created.
None
Q27. Your application is packaged in myapp.jar and depends on a jar named datalayer.jar, which in turn depends on mysql-connector-java-8.0.11.jar.
You have modularized myapp without waiting for datalayer and mysql driver to be modularized and the following are the contents of myapp's module-info:
module abc.myapp{
requires datalayer;
}
Assming that com.abc.myapp.Main is the main class of your application that you want to execute, which of the following commands will successfully launch your application?
Select 3 option(s):
java -classpath mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar com.abc.myapp.Main
java -module-path mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar com.abc.myapp.Main
java -p mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar -m com.abc.myapp.Main
java -p mysql-connector-java-8.0.11.jar;datalayer.jar;myapp.jar -m abc.myapp/com.abc.myapp.Main
java -cp mysql-connector-java-8.0.11.jar -p datalayer.jar;myapp.jar -m abc.myapp/com.abc.myapp.Main
Q28. Given the following interface definition, which definitions are valid?
interface I1{
void setValue(String s);
String getValue();
}
Select 2 option(s):
class A extends I1{
String s;
@Override
void setValue(String val) { s = val; }
String getValue() { return s; }
}
interface I2 extends I1{
void analyse();
}
abstract class B implements I1{
@Override
int getValue(int i) { return 0; }
}
interface I3 implements I1{
void perform_work();
}
abstract class B implements I1{
int getValue(int i) { return 0; }
}
Q29. What will the following code fragment print when compiled and run?
Locale myloc = new Locale.Builder().setLanguage("en").setRegion("UK").build(); //L1
ResourceBundle msgs = ResourceBundle.getBundle("mymsgs", myloc);
Enumeration en = msgs.getKeys();
while(en.hasMoreElements()){
String key = en.nextElement();
String val = msgs.getString(key);
System.out.println(key+" : "+val);
}
Assume that only the following two properties files (contents of the file is shown below the name of the file) are accessible to the code.
1. mymsgs.properties
okLabel=OK
cancelLabel=Cancel
2. mymsgs_en_UK.properties
okLabel=YES
noLabel=NO
Select 1 option(s):
It will not compile due to line L1.
It will not print anything.
okLabel=OK
cancelLabel=Cancel
okLabel=YES
noLabel=NO
noLabel : NO
okLabel : YES
cancelLabel : Cancel
noLabel : NO
okLabel : OK
cancelLabel : Cancel
None
Q30. Which of the following code snippets will print exactly 10?
1. Object t = Integer.valueOf(106);
int k = ((Integer) t).intValue()/10;
System.out.println(k);
2. System.out.println(100/9.9);
3. System.out.println(100/10.0);
4. System.out.println(100/10);
5. System.out.println(3 + 100/10*2-13);
6. int i = 21;
float j = i%9+2;
System.out.println((int)j);
Select 3 option(s):
1
2
3
4
5
6
Q31. What will be the output of the following code?
List letters = new ArrayList();
letters.addAll(List.of("a", "c", "b"));
Collections.sort(letters);
System.out.println(Collections.binarySearch(letters, "c"));
Collections.reverse(letters);
System.out.println(Collections.binarySearch(letters, "c"));
Select 1 option(s):
2
0
2
2
1
2
2
-4
2
An unpredicatable int value.
1
Exception at run time.
None
Q32. Given the following code fragment, which of the following lines would be a part of the output?
outer:
for ( var i = 0 ; i<3 ; i++ ){
for ( var j = 0 ; j<2 ; j++ ){
if ( i == j ){
continue outer;
}
System.out.println( "i=" + i + " , j=" + j );
}
}
Select 2 option(s):
i = 1, j = 0
i = 0, j = 1
i = 1, j = 2
i = 2, j = 1
i = 2, j = 2
Q33. Consider :
class A {}
class B extends A {}
class C extends B {}
Which of the following boolean expressions correctly identify when the variable o actually refers to an object of class B and not of class C?
Select 2 option(s):
(o instanceof B) && (!(o instanceof A))
!((o instanceof A) || (o instanceof B))
(o instanceof B) && (!(o instanceof C))
! ( !(o instanceof B) || (o instanceof C))
(o instanceof B) && !((o instanceof A) || (o instanceof C))
Q34. Which statements regarding the following code are correct?
class Outer
{
private void Outer() { }
protected class Inner
{
}
}
Select 1 option(s):
This code will not compile.
Constructor for Outer is public.
Constructor for Outer is private.
Constructor for Inner is public.
Constructor for Inner is protected.
None
Q35. Consider the following program...
public class Outer
{
private double d = 10.0;
//put inner class here.
}
Which of the following options can be inserted in Outer class?
Select 3 option(s):
class Inner
{
public void m1() { this.d = 20.0; }
}
abstract class Inner
{
static int i1;
public void m1() { d = 20.0; }
}
final class Inner
{
public void m1() { d = 20.0; }
}
private class Inner
{
public void m1() { d = 20.0; }
}
Q36. Given:
public class ValueHolder{
final int value;
*INSERT CODE HERE*
}
Which of the following options can be inserted in the above code independent of each other?
Select 2 option(s):
public ValueHolder() { value = 10; }
public void ValueHolder(int x) { value = x; }
public int ValueHolder(String s) { value = Integer.parseInt(s); return value; }
public ValueHolder(){ this("10"); }
public ValueHolder(String x) { value = Integer.parseInt(x, 2); }
public ValueHolder(int x) { value = x; }
public ValueHolder(){ this("1_0"); }
public ValueHolder(String x) { value = Integer.valueOf(x, 16); }
Q37. Consider the following code:
//Assume appropriate imports
class Person{
String name;
String dob;
public Person(String name, String dob){
this.name = name; this.dob = dob;
}
}
public class SortTest {
public static void main(String[] args) {
ArrayList al = new ArrayList();
al.add(new Person("Paul", "01012000"));
al.add(new Person("Peter", "01011990"));
al.add(new Person("Patrick", "01012002"));
//INSERT CODE HERE
for(Person a : al) System.out.println(a.name+" "+ a.dob);
}
}
What can be inserted in the code so that it will sort the collection of Persons by Person's dob attribute?
Select 1 option(s):
Collections.sort(al, new Comparable< Person >(){
public int compare(Person o1, Person o2) {
return o1.dob.compareTo(o2.dob);
}
});
Collections.sort(al, new Comparator< Person >(){
public int compare(Person o1, Person o2) {
return o1.dob.compareTo(o2.dob);
}
});
Collections.sort(al, new Comparable< Person >(){
public int compare(Person o1, Person o2) {
return o1.dob.compare(o2.dob);
}
});
Collections.sort(al, new Comparator< Person >(){
public int compare(Person o1, Person o2) {
return o1.dob.compare(o2.dob);
}
});
None
Q38. Consider these two interfaces:
interface I1
{
void m1() throws java.io.IOException;
}
interface I2
{
void m1() throws java.sql.SQLException;
}
What methods have to be implemented by a class that says it implements I1 and I2 ?
(Assume that IOException and SQLException do not have a parent-child relationship.)
Select 1 option(s):
Both, public void m1() throws SQLException and public void m1() throws IOException
public void m1() throws Exception
The class cannot implement both the interfaces simultaneously because they have conflicting methods.
public void m1() throws SQLException, IOException
None of the above.
None
Q39. Given:
public class TestClass{
public static boolean getBool(){
return true;
}
public static String getString(){
return "true";
}
public static void main(String args[]){
switch( getBool() ){
case true -> System.out.println("true");
default -> System.out.println("none");
}
}
}
What changes can be done so that it will print only true?
Select 1 option(s):
No change is necessary.
Call getString instead of getBool in the switch.
Call getString instead of getBool in the switch and also change the case label from true to "true".
Remove the default section of the switch block.
Add break; after System.out.println("true");
Call getString instead of getBool in the switch, change the case label from true to "true", and also add break; after printing true.
None
Q40. Your are modularizing your java application but it depends on commons-dbcp-0.9.jar, which is not modularized. So, you have decided to put this jar on the module-path. What module name will be given to the automatic module created for this jar?
Select 1 option(s):
commons.dbcp.0.9
commons.dbcp.0
commons-dbcp-09
commons.dbcp
commons-dbcp
None
Q41. Which statements, when inserted in the code below, will cause an exception at run time?
class B {}
class B1 extends B {}
class B2 extends B {}
public class ExtendsTest{
public static void main(String args[]){
B b = new B();
B1 b1 = new B1();
B2 b2 = new B2();
// insert statement here
}
}
Select 1 option(s):
b = b1;
b2 = b;
b1 = (B1) b;
b2 = (B2) b1;
b1 = (B) b1;
None
Q42. Consider the following code:
public class Logger{
private StringBuilder sb = new StringBuilder();
public void logMsg(String location, String message){
sb.append(location);
sb.append("-");
sb.append(message);
}
public void dumpLog(){
System.out.println(sb.toString());
//Empty the contents of sb here
}
}
Which of the following options will empty the contents of the StringBuilder referred to by variable sb in method dumpLog()?
Select 1 option(s):
sb.delete(0, sb.length());
sb.clear();
sb.empty();
sb.removeAll();
sb.deleteAll();
None
Q43. What will the following code print when compiled and run?
abstract class Calculator{
abstract void calculate();
public static void main(String[] args){
System.out.println("calculating");
Calculator x = null;
x.calculate();
}
}
Select 1 option(s):
It will not compile.
It will not print anything and will throw NullPointerException
It will print calculating and then throw NullPointerException.
It will print calculating and will throw NoSuchMethodError
It will print calculating and will throw MethodNotImplementedException
None
Q44. What will be the output when the following program is run?
package exceptions;
public class TestClass {
public static void main(String[] args) {
try{
doTest();
}
catch(MyException me){
System.out.println(me);
}
}
static void doTest() throws MyException{
int[] array = new int[10];
array[10] = 1000;
doAnotherTest();
}
static void doAnotherTest() throws MyException{
throw new MyException("Exception from doAnotherTest");
}
}
class MyException extends Exception {
public MyException(String msg){
super(msg);
}
}
(Assume that there is no error in the line numbers given in the options.)
Select 1 option(s):
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10
at exceptions.TestClass.doTest(TestClass.java:14)
at exceptions.TestClass.main(TestClass.java:5)
Error in thread "main" java.lang.ArrayIndexOutOfBoundsException
exceptions.MyException: Exception from doAnotherTest
exceptions.MyException: Exception from doAnotherTest
at exceptions.TestClass.doAnotherTest(TestClass.java:29)
at exceptions.TestClass.doTest(TestClass.java:25)
at exceptions.TestClass.main(TestClass.java:14)
None
Q45. Identify correct statements about the module system of Java.
Select 2 option(s):
A JImage can only include java artifacts such as compiled classes and properties files.
Main goals of the module system are to improve security with strong encapsulation and stability with reliable dependencies.
Code in modules and traditional JARs on the classpath cannot coexist in an application.
Modules have concealed packages for internal use and exported packages for shared code with other modules.
Only an application structured as modular can be run on a modular JDK.
Q46. Identify examples of unboxing.
Select 3 option(s):
int getValue(){ return new int[]{ 1 }; }
new ArrayList< Integer >().add(1);
List< Integer >.of(1, 2, 3 );
int ival = optionalInt.get(); //assuming optionalInt is of type Optional< Integer >
long lv = Integer.valueOf(10);
long lv = Integer.valueOf("b", 16);
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