Tut01 - EE3206/EE5805 Java Programming Application Tutorial 1 1 For each of the following code fragments decide whether it can be compiled If yes

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

View Full Document Right Arrow Icon
1 EE3206/EE5805 Java Programming & Application Tutorial 1 1. For each of the following code fragments, decide whether it can be compiled. If yes, determine the value of x after the execution of the code. If no, explain why. a) byte x = 0; x++; b) byte x = 127; c) byte x = 128; d) char x = '0'; x = x + 1; e) char x = '0' + 1; f) char y = '0'; char x = y + 1; g) final char y = '0'; char x = y + 1; h) int x = 3f * 4; i) int x = (int) 3f * 4; j) int x = (int) 3f * 4f; k) int x = 'f' * 4; l) float x = 1.0; m) float x; x = 1.0; n) double x; x = 1f; 2. For each of the following code fragments, decide whether it can be compiled. If yes, determine the output display of the execution of the code. If no, explain why. a) int x = 1, y = 2, z = 3; if (x > y) if (z > y) System.out.println(“y is the smallest”); else System.out.println(“y is not the smallest”); b.) boolean t = true, f = false; if (t && f) System.out.println(“t && f”); if (t && !f) System.out.println(“t && !f”); if (t || f) System.out.println(“t || f”); if (!!t & !f) System.out.println(“!!t & !f”);
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/11/2011 for the course EE 3206 taught by Professor Cwting during the Spring '07 term at City University of Hong Kong.

Page1 / 3

Tut01 - EE3206/EE5805 Java Programming Application Tutorial 1 1 For each of the following code fragments decide whether it can be compiled If yes

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

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