Premium

Oracle Advacned Java Advanced Certification Questions and Answers (Dumps and Practice Questions)



Question : You have been given below code, what is the expected behavior?
package com.hadoopexam;

import java.io.IOException;

public class Welcome extends Thread {

@Override
public void run() {
System.out.print("HadoopExam");
}

public static void main(String[] args) throws IOException, InterruptedException {
Welcome wel = new Welcome();
wel.start();
Thread.sleep(500);
System.out.print(".com ");
}
}
 : You have been given below code, what is the expected behavior?
1. It will give compile time error

2. It will give run time error

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will print "HadoopExam"

5. It will print "HadoopExam.com"


Correct Answer : Get Lastest Questions and Answer :
Explanation: As we can see, here we are calling start() method on Thread class. Hence, it will also print "HadoopExam" . However, we have called Thread.sleep(500) which
will ask current thread to waith 500 milli second. In this case main() thread will sleep for 500 ms. Hence, most of the time wel thread would be processed first and then main()
thread will be processed.




Question : You have a various runnable tasks, which needs to be executed one by one, based on their priority (Between to ). However, you are keep getting higher priority tasks
in the Queue and you lower priority tasks will never get an opportunity to being executed. Which of the following problem is discussed in above statement?

A. Deadlock
B. Starvation
C. Livelock
D. R ace condition

 : You have a various runnable tasks, which needs to be executed one by one, based on their priority (Between  to ). However, you are keep getting higher priority tasks
1. Deadlock

2. Starvation

3. Access Mostly Uused Products by 50000+ Subscribers

4. R ace condition


Correct Answer : Get Lastest Questions and Answer :
Explanation: It is a example of Starvation, lower priority tasks will never be executed because of higher priority tasks are keep processed.




Question : Which of the following definition are correct?

 : Which of the following definition are correct?
1. class Welocme {
public synchronized void foo() {}
}


2. abstract class Welcome {
public abstract synchronized void foo();
}


3. Access Mostly Uused Products by 50000+ Subscribers
public synchronized void foo();
}


4. A and C


Correct Answer : Get Lastest Questions and Answer :
Explanation: Abstract methods cannot be synchronized.


Related Questions


Question : You have been given below code, what is the expected behavior?
package com.hadoopexam;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

class Welcome {
public static void main(String[] args) {
ZoneId zoneId = ZoneId.of("Asia/Kolkata");
ZonedDateTime zonedDateTime = ZonedDateTime.of(LocalDateTime.now(), zoneId);
System.out.println(zonedDateTime.getOffset());
}
}
 : You have been given below code, what is the expected behavior?
1. It will not compile.

2. It will compile and print +5:30[Asia/Kolkata]

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will compile and print +5:30[UTC]

5. It will compile and print +5:30



Question : You have been given below code, what behavior is expected?

package com.hadoopexam;

import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;

class Welcome {
public static void main(String[] args) {
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_DATE;
LocalDate dateOfBirth = LocalDate.of(2016, Month.FEBRUARY, 29);
System.out.println(dateFormat.format(dateOfBirth));
}
}
 : You have been given below code, what behavior is expected?
1. It will give compile time error.

2. It will produce output as '2016-02-29'

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will produce output as '2016-Feb-29'



Question : You have been given following code, and running from a system which are installed in India on Saturday and month is November and Year is . What will be the behavior
of the code?
package com.hadoopexam;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

class Welcome {
public static void main(String[] args) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE",Locale.US);
System.out.println(formatter.format(LocalDateTime.now()));
}
}
 : You have been given following code, and running from a system which are installed in India on Saturday and month is November and Year is . What will be the behavior
1. It will not compile.

2. It will print NOVEMBER

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will print Satu.



Question : You have been given below code, what is the expected behavior from it?

package com.hadoopexam;

import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;

class Welcome {
public static void main(String[] args) {
OutputStream os = new FileOutputStream("HadoopExam.txt");
System.setErr(new PrintStream(os));
System.err.println("There is an Error while reading file");
}
}
 : You have been given below code, what is the expected behavior from it?
1. It will not compile.

2. It will compile and run perfectly and print the message in "HadoopExam.txt"

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will run and print message "New file created as it was not exist" on console



Question : You have passed following string in Console

"I am learning Advanced Java from HadoopExam.com".

Which of the following Code snippet will help above string from Console?
 : You have passed following string in Console
1. BufferedReader br = new BufferedReader(System.in);
String str = br.readLine();


2. BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();


3. Access Mostly Uused Products by 50000+ Subscribers
String str = isr.readLine();


4. String str = System.in.readLine();
String str;
System.in.scanf(str);



Question : You have been given below code, what is the expected behavior (Assuming you are not executing from eclipse)

package com.hadoopexam;

import java.io.Console;
import java.io.FileNotFoundException;

class Welcome {
public static void main(String[] args) throws FileNotFoundException {
Console console = System.console();
console.printf("%d %1$x %1$o", 16);
}
}
 : You have been given below code, what is the expected behavior (Assuming you are not executing from eclipse)
1. T his program crashes after throwing an IllegalFormatException

2. T his program crashes after throwing ImproperFormatStringException

3. Access Mostly Uused Products by 50000+ Subscribers

4. T his program prints: 16 10 20