SlideShare a Scribd company logo
CORE JAVA - BUG HUNT QUIZ
ganesh@codeops.tech
Ganesh Samarthyam
Question #0
Which browser does this code open?
a) Internet Explorer
b) Opera
c) FireFox
d) Safari
class Google {
public static void main(String []args) {
http://www.google.com
System.out.println("Hello world");
}
}
Question #1
class LongVal {
public static void main(String []s) {
long l = 0x22l;
System.out.printf("%ld", l);
}
}
Question #2
class NaNTest {
public static void main(String []s) {
double d = getVal();
if(d == Double.NaN)
System.out.println("d is NaN”);
}
private static double getVal() {
return Double.NaN;
}
}
❖ FindBugs names this bug as: “Doomed test for
equality to NaN”
❖ This code checks to see if a floating point value is
equal to the special Not A Number value (d ==
Double.NaN).
❖ special semantics of NaN: no value is equal to NaN,
including NaN.
❖ d == Double.NaN is always false
❖ Correct check: Use Double.isNaN(x)
Bug: (NaN == NaN) is false!
“95% of the folks out there
are completely clueless
about floating-point”
-James Gosling (in 1998
JavaOne keynote address)
Floating-point Numbers are Tricky!
Question #3
class Base {
    public Base() {
   foo();
    }
    public void foo() {
       System.out.println("In Base's foo ");
    }
}
    
class Derived extends Base {
    public Derived() {
       i = new Integer(10);
    }
    public void foo() {
       System.out.println("In Derived's foo " + i.toString());
    }
   private Integer i;
}
class Test {
    public static void main(String [] s) {
  new Derived().foo();
    }
}
Question #4
abstract class Printer {
private Integer portNumber = getPortNumber();
abstract Integer getPortNumber();
public static void main(String[]s) {
Printer p = new LPDPrinter();
System.out.println(p.portNumber);
}
}
class LPDPrinter extends Printer {
/* Line Printer Deamon port no is 515 */
private Integer defaultPortNumber = 515;
Integer getPortNumber() {
return defaultPortNumber;
}
}
Question #5
class Color {
int red, green, blue;
void Color() {
red = 10; green = 10; blue = 10;
}
void printColor() {
System.out.println("red: " + red + " green: " + green + " blue: " + blue);
}
public static void main(String [] args) {
Color color = new Color();
color.printColor();
}
}
Question #6
Supplier<String> s = () -> "hello world";
System.out.println(s.get());
What bytecode
instruction would
s.get() generate?
Question #7
class Vehicle {
public static void run() {
System.out.println("In Vehicle.run()");
}
public static void main(String[] args) {
Vehicle vehicle = null;
vehicle.run();
}
}
class Car {
public static void run() {
System.out.println("In Car.run()");
}
}
Question #8
class Base {
public void aMethod(int args) {
System.out.println("Called Base.method with value " + args);
}
}
class Derived extends Base {
public void aMethod(long args) {
System.out.println("Called Derived.method with value " + args);
}
}
class Overriding1 {
public static void main(String []args) {
Base b = new Derived();
b.aMethod(10);
}
}
Question #9
class IntArray {
public static void main(String[] args) {
Integer[] intArr = new Integer[3];
intArr[0] = 1;
intArr[2] = 3;
for(int anInt : intArr) {
System.out.println(anInt);
}
}
}
Question #10
class Downcast {
public static void main(String []args) {
byte b = 100;
int i = 100;
b += i;
System.out.printf("b = " + b);
}
}
ganesh@codeops.tech @GSamarthyam
www.codeops.tech slideshare.net/sgganesh
+91 98801 64463 bit.ly/sgganesh

More Related Content

PDF
Automatically Describing Program Structure and Behavior (PhD Defense)
DOCX
Php questions and answers
PDF
Basic c++ 11/14 for python programmers
PDF
2018 cosup-delete unused python code safely - english
DOCX
Computer science project work
PPSX
C# 6.0 - April 2014 preview
PPTX
Go Language Hands-on Workshop Material
ODP
OpenGurukul : Language : C++ Programming
Automatically Describing Program Structure and Behavior (PhD Defense)
Php questions and answers
Basic c++ 11/14 for python programmers
2018 cosup-delete unused python code safely - english
Computer science project work
C# 6.0 - April 2014 preview
Go Language Hands-on Workshop Material
OpenGurukul : Language : C++ Programming

What's hot (20)

PPT
Java 8 - CJ
PDF
PDF
Solid C++ by Example
PPT
Constructor,destructors cpp
PDF
C++ idioms by example (Nov 2008)
PDF
Антихрупкий TypeScript | Odessa Frontend Meetup #17
PDF
systems programming lab programs in c
PDF
Go Lang Tutorial
DOCX
C# labprograms
PDF
Insecure coding in C (and C++)
PDF
C++20 the small things - Timur Doumler
PPTX
C++17 std::filesystem - Overview
PDF
The best of AltJava is Xtend
PPTX
Mcq ppt Php- array
ODP
Hands on Session on Python
PDF
High performance web programming with C++14
PDF
Haxe by sergei egorov
PDF
Introduction to go language programming
PPTX
Summary of C++17 features
PDF
Introduction to JQ
Java 8 - CJ
Solid C++ by Example
Constructor,destructors cpp
C++ idioms by example (Nov 2008)
Антихрупкий TypeScript | Odessa Frontend Meetup #17
systems programming lab programs in c
Go Lang Tutorial
C# labprograms
Insecure coding in C (and C++)
C++20 the small things - Timur Doumler
C++17 std::filesystem - Overview
The best of AltJava is Xtend
Mcq ppt Php- array
Hands on Session on Python
High performance web programming with C++14
Haxe by sergei egorov
Introduction to go language programming
Summary of C++17 features
Introduction to JQ
Ad

Similar to Core Java Meetup #9 - Quiz Questions - 6th May (20)

PDF
Fnt software solutions placement paper
PDF
Java MCQ Important Questions and Answers
PPT
Java language fundamentals
PPT
Conceitos Fundamentais de Orientação a Objetos
PPT
Questões de Certificação SCJP
PDF
Test Bank for Java Programming, 7th Edition
PPTX
Java SE 17 Study Guide for Certification - Chapter 02
PDF
T1
PDF
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
PPTX
OCA_PREPARATION_OCA_1Z0-808_FlashCards.pptx
TXT
CORE JAVA
PDF
ITI COPA Java MCQ important Questions and Answers
DOCX
Simulado java se 7 programmer
PPTX
Java Quiz
PDF
All based on Zybooks = AP Java with zylabsPlease answer all questi.pdf
PDF
Get Test Bank for Java Programming, 7th Edition free all chapters
PDF
Java Interview Questions PDF By ScholarHat
DOC
MX Server is my friend
DOC
MX Server is my friend
DOC
MX Server is my friend
Fnt software solutions placement paper
Java MCQ Important Questions and Answers
Java language fundamentals
Conceitos Fundamentais de Orientação a Objetos
Questões de Certificação SCJP
Test Bank for Java Programming, 7th Edition
Java SE 17 Study Guide for Certification - Chapter 02
T1
All based on Zybooks = AP Java with zylabsQUESTION 1char[][] tab.pdf
OCA_PREPARATION_OCA_1Z0-808_FlashCards.pptx
CORE JAVA
ITI COPA Java MCQ important Questions and Answers
Simulado java se 7 programmer
Java Quiz
All based on Zybooks = AP Java with zylabsPlease answer all questi.pdf
Get Test Bank for Java Programming, 7th Edition free all chapters
Java Interview Questions PDF By ScholarHat
MX Server is my friend
MX Server is my friend
MX Server is my friend
Ad

More from CodeOps Technologies LLP (20)

PDF
AWS Serverless Event-driven Architecture - in lastminute.com meetup
PPTX
Understanding azure batch service
PDF
DEVOPS AND MACHINE LEARNING
PDF
SERVERLESS MIDDLEWARE IN AZURE FUNCTIONS
PPT
BUILDING SERVERLESS SOLUTIONS WITH AZURE FUNCTIONS
PPTX
APPLYING DEVOPS STRATEGIES ON SCALE USING AZURE DEVOPS SERVICES
PPTX
BUILD, TEST & DEPLOY .NET CORE APPS IN AZURE DEVOPS
PPTX
CREATE RELIABLE AND LOW-CODE APPLICATION IN SERVERLESS MANNER
PPTX
CREATING REAL TIME DASHBOARD WITH BLAZOR, AZURE FUNCTION COSMOS DB AN AZURE S...
PPTX
WRITE SCALABLE COMMUNICATION APPLICATION WITH POWER OF SERVERLESS
PPTX
Training And Serving ML Model Using Kubeflow by Jayesh Sharma
PPTX
Deploy Microservices To Kubernetes Without Secrets by Reenu Saluja
PDF
Leverage Azure Tech stack for any Kubernetes cluster via Azure Arc by Saiyam ...
PDF
YAML Tips For Kubernetes by Neependra Khare
PDF
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
PPTX
Monitor Azure Kubernetes Cluster With Prometheus by Mamta Jha
PDF
Jet brains space intro presentation
PDF
Functional Programming in Java 8 - Lambdas and Streams
PPTX
Distributed Tracing: New DevOps Foundation
PDF
"Distributed Tracing: New DevOps Foundation" by Jayesh Ahire
AWS Serverless Event-driven Architecture - in lastminute.com meetup
Understanding azure batch service
DEVOPS AND MACHINE LEARNING
SERVERLESS MIDDLEWARE IN AZURE FUNCTIONS
BUILDING SERVERLESS SOLUTIONS WITH AZURE FUNCTIONS
APPLYING DEVOPS STRATEGIES ON SCALE USING AZURE DEVOPS SERVICES
BUILD, TEST & DEPLOY .NET CORE APPS IN AZURE DEVOPS
CREATE RELIABLE AND LOW-CODE APPLICATION IN SERVERLESS MANNER
CREATING REAL TIME DASHBOARD WITH BLAZOR, AZURE FUNCTION COSMOS DB AN AZURE S...
WRITE SCALABLE COMMUNICATION APPLICATION WITH POWER OF SERVERLESS
Training And Serving ML Model Using Kubeflow by Jayesh Sharma
Deploy Microservices To Kubernetes Without Secrets by Reenu Saluja
Leverage Azure Tech stack for any Kubernetes cluster via Azure Arc by Saiyam ...
YAML Tips For Kubernetes by Neependra Khare
Must Know Azure Kubernetes Best Practices And Features For Better Resiliency ...
Monitor Azure Kubernetes Cluster With Prometheus by Mamta Jha
Jet brains space intro presentation
Functional Programming in Java 8 - Lambdas and Streams
Distributed Tracing: New DevOps Foundation
"Distributed Tracing: New DevOps Foundation" by Jayesh Ahire

Recently uploaded (20)

PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Transform Your Business with a Software ERP System
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPT
Introduction Database Management System for Course Database
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
Digital Systems & Binary Numbers (comprehensive )
2025 Textile ERP Trends: SAP, Odoo & Oracle
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
How to Choose the Right IT Partner for Your Business in Malaysia
How to Migrate SBCGlobal Email to Yahoo Easily
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Reimagine Home Health with the Power of Agentic AI​
Transform Your Business with a Software ERP System
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
VVF-Customer-Presentation2025-Ver1.9.pptx
history of c programming in notes for students .pptx
Odoo Companies in India – Driving Business Transformation.pdf
Softaken Excel to vCard Converter Software.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Introduction Database Management System for Course Database
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers

Core Java Meetup #9 - Quiz Questions - 6th May

  • 1. CORE JAVA - BUG HUNT QUIZ ganesh@codeops.tech Ganesh Samarthyam
  • 2. Question #0 Which browser does this code open? a) Internet Explorer b) Opera c) FireFox d) Safari class Google { public static void main(String []args) { http://www.google.com System.out.println("Hello world"); } }
  • 3. Question #1 class LongVal { public static void main(String []s) { long l = 0x22l; System.out.printf("%ld", l); } }
  • 4. Question #2 class NaNTest { public static void main(String []s) { double d = getVal(); if(d == Double.NaN) System.out.println("d is NaN”); } private static double getVal() { return Double.NaN; } }
  • 5. ❖ FindBugs names this bug as: “Doomed test for equality to NaN” ❖ This code checks to see if a floating point value is equal to the special Not A Number value (d == Double.NaN). ❖ special semantics of NaN: no value is equal to NaN, including NaN. ❖ d == Double.NaN is always false ❖ Correct check: Use Double.isNaN(x) Bug: (NaN == NaN) is false!
  • 6. “95% of the folks out there are completely clueless about floating-point” -James Gosling (in 1998 JavaOne keynote address) Floating-point Numbers are Tricky!
  • 7. Question #3 class Base {     public Base() {    foo();     }     public void foo() {        System.out.println("In Base's foo ");     } }      class Derived extends Base {     public Derived() {        i = new Integer(10);     }     public void foo() {        System.out.println("In Derived's foo " + i.toString());     }    private Integer i; } class Test {     public static void main(String [] s) {   new Derived().foo();     } }
  • 8. Question #4 abstract class Printer { private Integer portNumber = getPortNumber(); abstract Integer getPortNumber(); public static void main(String[]s) { Printer p = new LPDPrinter(); System.out.println(p.portNumber); } } class LPDPrinter extends Printer { /* Line Printer Deamon port no is 515 */ private Integer defaultPortNumber = 515; Integer getPortNumber() { return defaultPortNumber; } }
  • 9. Question #5 class Color { int red, green, blue; void Color() { red = 10; green = 10; blue = 10; } void printColor() { System.out.println("red: " + red + " green: " + green + " blue: " + blue); } public static void main(String [] args) { Color color = new Color(); color.printColor(); } }
  • 10. Question #6 Supplier<String> s = () -> "hello world"; System.out.println(s.get()); What bytecode instruction would s.get() generate?
  • 11. Question #7 class Vehicle { public static void run() { System.out.println("In Vehicle.run()"); } public static void main(String[] args) { Vehicle vehicle = null; vehicle.run(); } } class Car { public static void run() { System.out.println("In Car.run()"); } }
  • 12. Question #8 class Base { public void aMethod(int args) { System.out.println("Called Base.method with value " + args); } } class Derived extends Base { public void aMethod(long args) { System.out.println("Called Derived.method with value " + args); } } class Overriding1 { public static void main(String []args) { Base b = new Derived(); b.aMethod(10); } }
  • 13. Question #9 class IntArray { public static void main(String[] args) { Integer[] intArr = new Integer[3]; intArr[0] = 1; intArr[2] = 3; for(int anInt : intArr) { System.out.println(anInt); } } }
  • 14. Question #10 class Downcast { public static void main(String []args) { byte b = 100; int i = 100; b += i; System.out.printf("b = " + b); } }