Core Java - Quiz Questions - Bug Hunt
-
Upload
bangalore-container-conference-2017 -
Category
Software
-
view
102 -
download
2
Transcript of Core Java - Quiz Questions - Bug Hunt
![Page 2: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/2.jpg)
Programmer’s world :)java.lang.NullPointerExceptionat org.eclipse.jface.dialogs.DialogSettings.load(DialogSettings.java:278)at org.eclipse.jface.dialogs.DialogSettings.load(DialogSettings.java:306)at org.eclipse.jface.dialogs.DialogSettings.load(DialogSettings.java:247)at org.eclipse.jface.dialogs.DialogSettings.load(DialogSettings.java:264)at org.eclipse.ui.plugin.AbstractUIPlugin.loadDialogSettings(AbstractUIPlugin.java:411)at org.eclipse.ui.plugin.AbstractUIPlugin.getDialogSettings(AbstractUIPlugin.java:232)at org.eclipse.jdt.internal.ui.JavaPlugin.getDialogSettingsSection(JavaPlugin.java:1012)at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart.<init>(PackageExplorerPart.java:436)at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)at java.lang.reflect.Constructor.newInstance(Unknown Source)at java.lang.Class.newInstance0(Unknown Source)at java.lang.Class.newInstance(Unknown Source)at org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI.createExecutableExtension(RegistryStrategyOSGI.java:170)at org.eclipse.core.internal.registry.ExtensionRegistry.createExecutableExtension(ExtensionRegistry.java:867)at org.eclipse.core.internal.registry.ConfigurationElement.createExecutableExtension(ConfigurationElement.java:243)at org.eclipse.core.internal.registry.ConfigurationElementHandle.createExecutableExtension(ConfigurationElementHandle.java:51)at org.eclipse.ui.internal.WorkbenchPlugin$1.run(WorkbenchPlugin.java:267)at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)at org.eclipse.ui.internal.WorkbenchPlugin.createExtension(WorkbenchPlugin.java:263)at org.eclipse.ui.internal.registry.ViewDescriptor.createView(ViewDescriptor.java:63)at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:328)at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:230)at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:594)at org.eclipse.ui.internal.Perspective.showFastView(Perspective.java:2053)at org.eclipse.ui.internal.Perspective.setActiveFastView(Perspective.java:1835)at org.eclipse.ui.internal.Perspective.setActiveFastView(Perspective.java:1848)at org.eclipse.ui.internal.Perspective.toggleFastView(Perspective.java:2241)at org.eclipse.ui.internal.WorkbenchPage.toggleFastView(WorkbenchPage.java:3824)at org.eclipse.ui.internal.ShowFastViewContribution.showView(ShowFastViewContribution.java:157)at org.eclipse.ui.internal.ShowFastViewContribution.access$1(ShowFastViewContribution.java:155)at org.eclipse.ui.internal.ShowFastViewContribution$3.widgetSelected(ShowFastViewContribution.java:138)at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
SNAFU!
![Page 3: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/3.jpg)
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"); } }
![Page 4: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/4.jpg)
Question #1
![Page 5: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/5.jpg)
![Page 6: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/6.jpg)
Question #2
![Page 7: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/7.jpg)
“95% of the folks out there are completely clueless
about floating-point”
-James Gosling (in 1998 JavaOne keynote address)
Floating-point Numbers are Tricky!
![Page 8: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/8.jpg)
Another Example
class FloatCompare { public static void main(String []args) { double x = 2.0; double y = Math.sqrt(x) ; System.out.println( (y * y) == x); } }
![Page 9: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/9.jpg)
Question #3
![Page 10: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/10.jpg)
Question #4
Which one of the following best describes the behavior of this code?
a) This code segment will give compiler error(s) b) This code segment will return 1 to the caller c) This code segment will return null to the caller d) This code segment will result in throwing a NullPointerException
![Page 11: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/11.jpg)
Question #5class Append { public static void main(String []args) { StringBuffer sb = new StringBuffer('H'); sb.append('i'); System.out.println(sb); } }
Which one of the following best describes the behavior of this code?
a) This code segment will give compiler error(s) b) This code segment will print “Hi” c) This code segment will print “H” d) This code segment will print “i”
![Page 12: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/12.jpg)
Question #6class ReplaceAll { public static void main(String []args) { String date = "18-03-2017" ; String date1 = date.replaceAll( "-" , "." ) ; String date2 = date1.replaceAll( "." , "/" ) ; System.out.println(date2); } }
What is the output of this program?
a) 18-03-2017 b) ---------- c) ………. d) //////////
![Page 13: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/13.jpg)
Question #7
![Page 14: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/14.jpg)
Question #8
![Page 15: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/15.jpg)
Question #9class Base { public Base() { System.out.println("In Base ctor"); } }
class Derived extends Base { public Derived() { System.out.println("In Derived ctor"); } }
class UseArray { public static void main(String []args) { Base [] array = new Derived[2]; array[0] = new Base(); array[1] = new Derived(); } }
![Page 16: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/16.jpg)
Question #10class Stack {
private final int CAPACITY = 100; private Object[] array = new Object[CAPACITY]; private int size = 0;
public void push(Object val) { if (size < CAPACITY)
array[size++] = val; else
throw new StackFullException(); }
public Object pop() { if (size == 0)
throw new StackEmptyException(); else return array[--size];
}}
![Page 17: Core Java - Quiz Questions - Bug Hunt](https://reader030.fdocuments.us/reader030/viewer/2022020301/58d0f97e1a28abc00b8b5bbf/html5/thumbnails/17.jpg)
[email protected] @GSamarthyam
www.codeops.tech slideshare.net/sgganesh
+91 98801 64463 bit.ly/sgganesh