Daddy Quiz Solution

Daddy Quiz Solution - Name Roll Number CS 391 Advanced Programming in Java Autumn 2005 ~Grand Daddy Quiz~ 30 minutes 80 marks Date[Closed

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Name: __________________ Roll Number : __________________ CS 391 Advanced Programming in Java Autumn 2005 ~Grand Daddy Quiz~ 30 minutes - 80 marks Date : 22/09/05 [Closed Book/Closed Notes/Open Mind] All the very best ! SCOREBOARD Question 1 2 3 4 5 6 7 8 9 10 11 Marks
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ROUND I: SNIPPING THE CODES Question 1  [ 5 marks] Assume we have a file named “file.txt” and the first line of this text file reads “Java Ka Cheetah”. What will be the output of the following code then? FileReader fr = new FileReader("file.txt"); BufferedReader br = new BufferedReader(fr); String name = br.readLine(); if(name=="Java Ka Cheetah") { System.out.println("The name is Java Ka Cheetah!"); } else { System.out.println("Say Java Java!"); } ANS: Unknown because == compares address not value, address may or may not be the same.
Background image of page 2
Question 2  [3 marks] Assuming that an IOException is generated in the try block of the code below, what output would the user see on the console? try { /*Code throws IO exception*/ } catch(Exception ex) { System.out.printLn("A"); } catch(IOException ioex) { System.out.printLn("B"); } Ans > A
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What will be the output of the following code? public class Test { int x=0; int y=10; public static void main (String args[]) { x = 5; y = 6 + 9*2; y = x + 4*y; System.out.println(y); } } Ans> Compile-time error because variables are not static For Section people only: There was a typing error in this question.(String args[]) was not present. But the error was mentioned in Section 2. So, partial credit is given to those students who had mentioned this missing “String args[]”.And full credit is not given, since there was some other error as well “ Compile- time error because variables are not static”. For section 2 people, partial credit will not be given since it was mentioned in your
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/09/2010 for the course CS CS300 taught by Professor Abh during the Spring '10 term at lln.

Page1 / 14

Daddy Quiz Solution - Name Roll Number CS 391 Advanced Programming in Java Autumn 2005 ~Grand Daddy Quiz~ 30 minutes 80 marks Date[Closed

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online