How much do you know about Java?

10
int k = Integer.MAX_VALUE; k++; hat happens when the following code executes? byte b = someFile.readByte(); b = (byte)(b >>> 2); //shift bit string right by two bits ose that the byte read is the bit string 10000000 is the value of b after executing the following?

description

How much do you know about Java?. What happens when the following code executes?. int k = Integer.MAX_VALUE; k++;. Suppose that the byte read is the bit string 10000000 What is the value of b after executing the following?. byte b = someFile.readByte(); - PowerPoint PPT Presentation

Transcript of How much do you know about Java?

Page 1: How much do you know about Java?

int k = Integer.MAX_VALUE;k++;int k = Integer.MAX_VALUE;k++;

What happens when the following code executes?

byte b = someFile.readByte();b = (byte)(b >>> 2); //shift bit string right by two bitsbyte b = someFile.readByte();b = (byte)(b >>> 2); //shift bit string right by two bits

Suppose that the byte read is the bit string 10000000What is the value of b after executing the following?

Page 2: How much do you know about Java?

public class Child extends Parent { . . . // the following is an invalid instruction super.super.foo(); . . .}

public class Child extends Parent { . . . // the following is an invalid instruction super.super.foo(); . . .}

Suppose the Grandparent class contains a parameterless voidmethod named foo, that is overridden by a Parent subclass whichin turn s overridden by its Child subclass. Within the Child classhow can you call the Grandparent version of foo?

public class Example<E> { E generic object = ?}

public class Example<E> { E generic object = ?}

How do you create an object of generic type?

Page 3: How much do you know about Java?

CS/421 is not a programming course!

CS/421 is not a survey of languages course!

Page 4: How much do you know about Java?

Classification by “Power” machine language

- a program instruction is a number- programs are “understood” by computer hardware

assembler language- a program instruction is a mnemonic version of the corresponding machine instruction

high-level language- language constructs are designed with the programmer in mind

parallel language- a program is a group of tasks that execute simultaneously

Page 5: How much do you know about Java?

Classification by Intended Application general purpose … e.g. PL/1

scientific/engineering applications … e.g. FORTRAN business applications … e.g.s COBOL, RPG

systems programming … e.g.s C, PL/S, Bliss real time systems … e.g.s Ada, Jovial list processing … e.g.s LISP, SLIP, Scheme string processing … e.g.s Snobol, Icon

set processing … e.g. SETL Web applications … e.g. Java

script programming … e.g.s Perl, PHP, Javascript

Page 6: How much do you know about Java?

“Classification” by User Interface compiled

Each program (the source code) must be translatedinto machine language form for execution.

interpretedThe source code instructions are analyzed individually as they are executed.

Page 7: How much do you know about Java?

Classification by Paradigm imperative / procedural programming program = sequence of instructions (usually including loops & procedures) variables & assignments used liberally key control structure: repetition (while/for) key data structure: array examples: Ada, C, Cobol, FORTRAN, Pascal, PL/1

functional / applicative programming program = a function to be evaluated key control structure: recursion key data structure: list examples: LISP, Scheme, ml

Page 8: How much do you know about Java?

Classification by Paradigm (continued) object-oriented programming program = sequence of operations (methods) applied to objects an object incorporates both data and associated operations examples: Smalltalk, Eiffel, Java, C#

logic-based / relational programming program = a collection of rules and goals program execution is based on theorem proving concepts example: Prolog

Page 9: How much do you know about Java?

language year author(s) intended purpose FORTRAN 1957 J. Backus/IBM scientific LISP 1958 McCarthy (MIT) list processing (A.I.) ALGOL 58/60 1958 Intn’l committee general COBOL 1959 Hopper/committee business D.P. APL 1960 Iverson/Harvard/IBM matrices/scientific SNOBOL 1962 Griswold/Bell Labs string processing BASIC 1963 Kemeny & Kurtz education PL/1 1963 SHARE Com./IBM general Simula 1963 Dahl et. al. general/simulation ALGOL 68 1967 Intn’l committee general Bliss 1971 Wulf/CMU systems programming Pascal 1971 Wirth/ETH-Zurich general/education Prolog 1972 Colmerauer/Kowalski logic-based (A.I.)

Page 10: How much do you know about Java?

language year author(s) intended purpose C 1972 Ritchie/Bell Labs systems programming Conc.Pascal 1975 Hansen/CA-Tech parallel programming Scheme 1975 Steele/Sussman/MITlists/A.I. Euclid 1977 Committee verifiable prog. Gypsy 1977 U of TX verifiable prog. Modula-2 1977 Wirth/ETH general ML 1978 Milner/EdinburghMachine-assisted proof Ada 1979 DOD committee real-time Smalltalk 1980 Kay/Xerox PARC object-oriented C++ 1986 Stroustrup/Bell Labsobject-oriented C Eiffel 1990 Bertrand Meyer object-oriented Java 1994 Gosling/SunWeb/object-oriented C# 2001 Microsoft basis for .net