📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
✅ Some premium posts are free to read — no account needed. Follow me on Medium to stay updated and support my writing.
🎓 Top 10 Udemy Courses (Huge Discount): Explore My Udemy Courses — Learn through real-time, project-based development.
▶️ Subscribe to My YouTube Channel (172K+ subscribers): Java Guides on YouTube
Check out Part 1 - Oracle Java Certification Exam Sample Questions - Part 1.
Check out Part 2 - Oracle Java Certification Exam Sample Questions - Part 2.
1. Given:
public class App {
static void doCalc(byte...a) {
System.out.print("byte...");
}
static void doCalc(long a, long b) {
System.out.print("long, long");
}
static void doCalc(Byte s1, Byte s2) {
System.out.print("Byte, Byte");
}
public static void main(String[] args) {
byte b = 5;
doCalc(b, b);
}
}
Answer
2. Which code fragment correctly assigns a numeric literal?
byte b1 = b1011;
byte b2 = 1011b;
byte b3 = 0b1001;
byte b4 = 0xb001;
Answer
byte b3 = 0b1001;
3. Given the fragment:
public class MathFun {
public static void main(String[] args) {
int number1 = 0b0111;
int number2 = 0111_000;
System.out.println("Number1: " + number1);
System.out.println("Number2: " + number1);
}
}
Number1: 7
Number2: 7
Number1: 7
Number2: 111_000
Number1: 0b0111
Number2: 0111000
Answer
Number1: 7
Number2: 7
4. What is the output of the following program?
public class Test {
public static void main(String[] args) {
String s1 = "hello";
String s2 = new String("hello");
s2 = s2.intern();
System.out.println(s1 == s2);
}
}
Answer
b) true
5. Consider the following program and choose the correct option from the list of options:
class Base {
public void test() {
}
}
class Base1 extends Base {
public void test() {
System.out.println("Base1");
}
}
class Base2 extends Base {
public void test() {
System.out.println("Base2");
}
}
class Test {
public static void main(String[] args) {
Base obj = new Base1();
((Base2) obj).test(); // CAST
}
}
Answer
d) The program will result in an exception (ClassCastException).
Check out Part 1 - Oracle Java Certification Exam Sample Questions - Part 1.
Check out Part 2 - Oracle Java Certification Exam Sample Questions - Part 2.
Comments
Post a Comment
Leave Comment