Week2Assignment

Week2Assignment - { public static void main ( String [ ]...

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

View Full Document Right Arrow Icon
Introduction to Java Assignment CS 180 Sunil Prabhakar Department of Computer Science Purdue University
Background image of page 1

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

View Full DocumentRight Arrow Icon
Q1 Which of the following is a legal Java declaration for an identifier? A. 3.116PI B. new C. happy-hour D. demolition Derby E. DOUBTFUL 2
Background image of page 2
Q2 Which of the following is not a legal Java identifier? A. MyRegistration1 B. my_1Registration C. myRegistration1 D. 1myRegistration E. $myRegistration$ 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
Q3 Which of the following will not be treated as comments by the Java compiler? 4 /* I hope this is part of the comment */ A /* I hope this is part of the comment /* B // I hope this is //part of the // comment /* C // I hope this is //part of the /* comment /* D /* I hope this is /* part of the comment */ */ E
Background image of page 4
Q4 5 import javax.swing.*; class HelloWorld
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { public static void main ( String [ ] args ) { JFrame MyWindow; myWindow = new JFrame ( ) ; MyWindow.setSize ( 300, 200 ) ; } } Why won't this code compile? A. MyWindow is an illegal identifier B. myWindow is not declared C. setTitle() is not called D. Looks like it will compile. Q5 6 import javax.swing.*; class HelloWorld { public static void main ( String [ ] args ) { JFrame myWindow, firstName; firstName = new String ( ) ; firstName = new JFrame ( ) ; } } Why won't this code compile? A. firstName can't be used as an identifier for a JFrame object B. myWindow is not used in the program C. firstName can't be assigned a String object D. This should compile....
View Full Document

Page1 / 6

Week2Assignment - { public static void main ( String [ ]...

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

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