Java Certification Model Question & Answer
|
|
- Lynette Lynch
- 5 years ago
- Views:
Transcription
1 Java Certification Model Question & Answer - 4 Java Certification, Programming, JavaBean and Object Oriented Reference Books Sun Certified Programmer for the Java2 Platform Mock Exam S:- Which of the following are valid assignment expressions, given the following declarations:- byte b; int i = 10; long l = 20; b = i; b += i; b++; b = b + i; Answer State true or false: Interface methods can be declared static true false Answer Select the correct answers: If you define a class within an interface, the class is always public the class is always static the class methods cannot call methods declared in the interface Answer State true or false: An abstract class can have a constructor true false Answer What is the output of the following piece of code: class A { public A() { class B{ Gianeshwar Singh 1
2 B() { System.out.println("In no-arg constructor"); new B(); public A(int a) { class B{ B() { System.out.println("In constructor with an int argument"); new B(); public static void main( String[] args{ A a1 = new A(); A a2 = new A(10); Code does not compile Code compiles but generates exception at runtime Code compiles successfully and outputs In no-arg constructor In constructor with an int argument Answer Select all correct answers: Numeric operators that throw the ArithmeticException on integer operands include + - / % * Answer What is the output of the following piece of code. System.out.println("-0.0 == 0.0 returns " + (-0.0 == 0.0)); System.out.println("0.0 > -0.0 returns " + (0.0 > -0.0)); Gianeshwar Singh 2
3 Answer Select true or false: The equality operator (==) always returns false if either operand is Nan and the inequality operator (!=) return true if either operand is Nan. true false Answer Select the correct answers: You can use an instance of a File class to do the following delete a file change current working directory rename files create new sub-directories Answer What is the output of the following code: public class Temp{ public static void main(string[] args){ String[] a = null; System.out.println("The length of the array is " + a.length): The code does not compile The code compiles and prints out "The length of the array is 0"; The code compiles and prints out "The length of the array is null"; The code compiles but generates the NullPointerException at runtime Answer Given the following declaration: char a; Which of the following are valid values that can be assigned to a? \0 \u003c Gianeshwar Singh 3
4 \349 \u004 \345 Answer Given the following code, what is the output generated class Base { public static void amethod(){ System.out.println("In base amethod"); public void another(){ System.out.println("In base another"); static int staticint = 10; int instancevar = 20; public class Child extends Base { public static void amethod(){ System.out.println("In child amethod"); public void another() { System.out.println("In child another"); static int staticint = 30; int instancevar = 40; public static void main(string[] a ){ Base b = new Child(); b.amethod(); b.another(); System.out.println("Value of staticint is = " + b.staticint); System.out.println("Value of instancevar is = " + b.instancevar); Code does not compile Code compiles and prints out In base amethod In child another Value of staticint is 30 Gianeshwar Singh 4
5 Value of instancevar is 40 Code compiles and prints out In base amethod In child another Value of staticint is 10 Value of instancevar is 20 Code compiles and prints out In child amethod In child another Value of staticint is 30 Value of instancevar is 40 Answer Select all correct answers: Modifiers that you CANNOT use with constructors include private abstract static public final Answer State true or false: The RandomAccessFile class is compatible with the Stream classes True False Answer Gianeshwar Singh 5
6 What is the output of the following piece of code: class A{ public static void main(string[] args){ int i = 1; int j = 5; System.out.println((i++ * j)); System.out.println("i = " + i + " j = "+ j); System.out.println((++i * j)); System.out.println("i = " + i + " j = " + j); Code does not compile Code compiles and prints out 10 I = 2 j=5 15 I = 3 j = 5 Code compiles and prints out 5 I = 2 j=5 15 I = 3 j = 5 Answer S:- b, c Remember, that a compound assignment expression of the form E1 op= E2 is always equivalent to E1 = (Type) (E1 op E2), where Type is the type of E1. b Gianeshwar Singh 6
7 The only modifiers that are allowed with interface methods are public and abstract. And these are implicit, so you don t even have to include them. a,b,c All three are right. Classes defined within an interface are implicitly public and static and because you cannot have static methods within an iterface, you cannot refer to the non-static methods from the static class methods. a c c, d The only operators that can cause an ArithmeticException are the integer division (/) and modulo (%) operators. Remember that float operations do not raise any exception at all. They may result in NaN or Infinities, instead == 0.0 returns true -0.0 > 0.0 returns false a Gianeshwar Singh 7
8 a, c, d d a, b, d Check out the Java Language Specification for more information on Character Literal and Escape Sequences c Static variables and methods as well as instance variables use the Type of the reference variable to determine the correct variable/method to use. On the other hand, instance methods use the Class of the reference variable to determine the correct method to call b,c,e Unlike methods, a constructor cannot be abstract, static, final, strictfp, native or synchronized. b c Back to questions Return to : Java Programming Hints and Tips Java Certification, Programming, JavaBean and Object Oriented Reference Books Sun Certification for Java2 Programming what is the output of following code? Gianeshwar Singh 8
9 public class Test { public static void main(string[] args){ int i = 4, j = 7; String k = "string"; System.out.println(i+j+k+i+j); a. 47sting47 b. 11string11 c. 47string11 d. 11string47 e. Non of above is correct d What will happen if compile and run the following code? public class Test { public static void main(string[] args){ StringBuffer k = new StringBuffer("string"); StringBuffer s = new StringBuffer("String"); if (s.equals(k)) System.out.println("Yes"); else System.out.println("No"); a print out "Yes" b print out "No" c compile error d run time exception e. Non of above is correct b Gianeshwar Singh 9
10 You design a GUI with lots of components whose fonts and background colours are different, it looks very nice. Because Java is platform independent, its appearance will be excectly the same in other platform. a. Yes b. Yes, but only if use same Java version c. No d. No, because Java is not platform independent. c what is the result of the following code long i = 1,j; j = i<< 35; System.out.println(j) a. copmpiling or run time error b. 2 power 3 = 8 c. 2 power 5 = 32 d. 2 power 34 e. 2 power 35 f. 2 power 36 e what will appear on screen after perform following code Gianeshwar Singh 10
11 public class Test{ public static void main(string[] args){ From f = new Frame("Test"); Button a = new Button("A"); Button b = new Button("B"); Button c = new Button("C"); Button d = new Button("D"); f.add(a); f.add(b); f.add(c); f.add(d); a. A button label "D" in centre of a frame, occupying whole frame. b. Four buttons label "A","B","C" and "D" lay one by one inside the frame. c. there are four buttons on screen d. see nothing on screen d what is default layout of dialog component a. FlowLayout b. BorderLayout c. GridLayout d. CardLayout e. GridBagLayout b EXPLANATION default layout for applet is FlowLayout Frame has BorderLayout same as Dialog Gianeshwar Singh 11
12 int j; for (int i =3,j=1;j++,i--;j<3) if (j== i) contiune; System.out.println("i="+i+" j="+j) what is the output of above code fragment. a. run time error or exception throw b. compiling error c. i = 1 j = 1 d i = 2 j = 1 e. i = 3 j = 1 f. i = 2 j = 2 g. i = 2 j = 3 h. i = 3 j = 3 b EXPLANATION for statment initial error, cannot mix initial and assigment together. class Outer{ static class Inner{ Given that in your class myapp, you need a reference to Inner object. which of following code fragment shows the correct way to declare and initialize a reference to a Inner object a. Outer.Inner myinner = new Outer.Inner() Gianeshwar Singh 12
13 b. Inner myinner = new Outer.Inner() c. Outer.Inner myinner = Outer.new Inner() d. Inner myinner = Outer.new Inner() f. Outer.Inner myinner = new Outer.new Inner() e. Inner myinner = new Outer.new Inner() g. Inner myinner = new Outer.Inner() g class Outer{ class Inner{ Given that in your class myapp, you need a reference to Inner object. which of following code fragment shows the correct way to declare and initialize a reference to a Inner object a. Outer.Inner myinner = new Outer.Inner() b. Inner myinner = new Outer.Inner() c. Outer.Inner myinner = new Outer.new Inner() d. Inner myinner = new Outer.new Inner() e. Outer outer = new Outer(); Outer.Inner myinner = new Outer.new Inner() c e //file Test.java class A implements Runnable{ public void run(){ i+=1; Gianeshwar Singh 13
14 void printi(){system.out.println("i="+i); int i = 1; public class Test{ public static void main(string[] args){ A a= new A(); a.printi(); Thread t = new(a); t.start(); a.i +=1; a.print(); compile and run above code, what will be output? a. compile error b. run time error c. i = 1, i = 1; d. i = 1, i = 2; h. output unpredictable h EXPLANATION two thread shared the same data, should use synchronized key word class Parent{ int i = 0; void amethod(){system.out.println("in Parent"); class Child extends Parent{ int i = 10; void amethod(){system.out.println("in Child"); Gianeshwar Singh 14
15 class Test{ public static void main(string[] args){ Parent p = new Child(); Child c = new Child(); System.out.print("i="+p.i+" "); p.amethod(); System.out.print("i="+c.i+" "); c.amethod(); what will appear in output of above code? a. i = 0 in Parent b. i = 0 in Child c. i = 10 in Parent d. i = 10 in Child c. compiler or run time error b d EXPLANATION only member method can be overriden, not member variable class A{ int j; A(int i){j = i; public class B extends A{ B(int i){j=i*2; public static void main(string[] arges){ A b = new B(1); System.out.println("b.j = "+b.j); Gianeshwar Singh 15
16 what is output of above code? a. compile error b. run time error c. b.j = 1 d. b.j = 2 a EXPLANATION Deault constraction must be defined, if subclass constraction need to use it. class Test{ public static void main(string[] arg){ short i,j; i = 10; j= -i*10; System.out.println("j="+j); what will be output after compile and run about code. a. compile error b. runtime error c. j= -100 d. non of above is correct a EXPLANATION in j = -i*10// "-" turn -i to be int Gianeshwar Singh 16
17 which of following statements are true. select all correct answer. a). A private number(method or variables) only can be accessed under current instance. b). A class number(class,method or variable) may have one of following access modifier; public, default, protected or private. c). The only access modifier you can put before a top level class is public. d). Assume class C extends B, class B extends A, class A has a method action(), which is overridden by class B and class C. But inside an instance of class C, you still can get action() of class A version,by use "super.super.action()". e). Protected feature means it available to all classes in the same package, and available to all subclasses of the class a is correct b is correct c is correct d is correct e is correct d none of them correct c e EXPLANATION a, private means private to class, i.e can accessed by any instance of that class b, default is not a legal access modifier. d, "super.super." is illegal. variables a,b,c and results are type of long. what is the best way to caculating results = a*b/c? a). results = a*(b/c) b). results = (a*b)/c c). results = a/c*b Gianeshwar Singh 17
18 d). a,b,c will produce exactly the same results. b EXPLANATION for integer 9/2 equal to 4 Assume a and result are float, i.e float a, result; after caculating as; result = sqt(a); How can you know that variable results is a NaN a). if (result >= Float.NaN) b). if (result <= Float.NaN) c). if (result == Flaot.NaN) d). use try{ and catch to catch exception e). non of a,b,c and d are correct. e EXPLANATION the correct way to compare NaN is use Float.isNaN(float i) which is legal? a. boolean isboolean = null; b. char c = '\u4507'; c. double d = 1.0/0.0; d. byte a = 256; e. String str = null; f. String str = "c:\"; Gianeshwar Singh 18
19 b c e EXPLANATION a, boolean type only can take false or true as value c, d= +infinity d, out of range f, correct is String str = "c:\\" True or False; Assign null to a reference variable which you have finished with it can improve performence. a. true b. false a which is true? a). Shift operators may be applied only to oprands of either int or long b). A array declare inside a mothed will not be initialized by system just like methed local variable. c). JVM need Garbage Collection because reference variables allocated on the stack while object is allocated on the heap. d). Java has Garbage Collection ability, so software written by Java will never have memory leaks or run out of memory problem a c Gianeshwar Singh 19
20 EXPLANATION b false array always get initialzed by system d false if you keep create object, sooner or later menory will run out. class Test{ public static void main(string args[]){ int total; for(int i = 0 ; i<10;){ total += i; i++; System.out.println("total = "+total+" : i = "+i); what is output of above code? a). compile error b). run time error c). output: total = 55 : i = 10 d). output: total = 55 : i = 9 a EXPLANATION System.out.println("total = "+total+" : i = "+i), i out of scope which of the following code is legal? a). int total = 0; for (int i=7, long j=0;i<10;j++) total += i; Gianeshwar Singh 20
21 b). int x =038 System.out.println("x="+x); c). public class A{ public amethod(int i){ public int j=0; j=i*2; d). int x =034 System.out.println("x="+x); d which of the following construction is legal a). RandomAccessFile("Text.txt", "rw") b). RandomAccessFile("Text.txt", 'r') c). RandomAccessFile("Text.txt", "r") d). RandomAccessFile("Text.txt", "w") e). RandomAccessFile("Text.txt", 'w') a c which collections can have duplicates data a). Collection b). List c). Set Gianeshwar Singh 21
22 d). Map a b Witch of the following statement is true. a). An object whose class implement Runnable interface, if you call run() in main thread instead of start(), run() will not execute. b). The signature of main is, static public main(string[] arge) c). Assume a is a Array, statement a.length = 10, will get compiler error. c Witch of the following is legal. a). float a = 1; b). float a = 1.0; c). char a = \u0000; d). char a = 12; e). int i = 12; char a = i; a d EXPLANATION b. should be; float a = 1.0f; c. should be; char a = '\u0000' e. should be; char a = (char)i; Gianeshwar Singh 22
23 What is '\u0000' represented? a). null character b). equivalent to decimal 0(zero) c). space ascii d). a,b,c and d all wrong a b What is the ouput of the following code? public class test { static StringBuffer str = new StringBuffer("Hello world"); public static void amethod1(stringbuffer s){ s = new StringBuffer("Good bye world"); public static void amethod2(stringbuffer s){ s.append("!"); public static void main(string[] args){ amethod1(str); System.out.println(str); amethod2(str); System.out.println(str); a). Hello world Hello world! b). Hello world Hello world c). Good by world Good by world d). Good by world Good by world! e). Good by world Hello world d). Hello world Good by world Gianeshwar Singh 23
24 f). Good by world Hello world! g). Hello world Good by world! a Assume str = "red", compile and run a program which will call the following code, the results will be, boolean amethod(string str){ switch (str){ case "Red" case "red" System.out.println("It is Red!"); case "Blue" case "blue": System.out.println("It is Blue!"); break; case "Green": case "green": System.out.println("It is Green!"); a). output "It is Red!" b). output "It is Blue!" c). output "It is Green!" d). output "It is Red! ", follow by "It is Blue!" e). run time error. f). compile time error. f Select the best statment to replace the comment of line 1. Gianeshwar Singh 24
25 try{ // line 1 BufferedReader b = new BufferedReader(f); catch(filenotfoundexception e){ System.out.println("FileNotFoundException "+e); a). BufferedInputStream f = new BufferedInputStream("text.txt"); b). File f = new File("text.txt"); c). FileInputStream f = new FileInputStream("text.txt"); d). FileReader f = new FileReader("text.txt"); d Which of the following statments is true? a).java arrays may be assume as static arrays, that means size has to be specified at compile time. b).thread is a abstract class, as method void run() must be implmented. c). With &,^ and operations, the two operands may be of any types of boolean, byte, short, int and long, even mix of these types, just like +, - operatins. d). With operations && and, they only can be apply to boolean operands. a Compile and run the following code, what will happen? class Try{ public static void main(string arg[]){ int i,j,k; k = 2; for( i=0; i < k*2; j=(i++)*2) System.out.println("j="+j); Gianeshwar Singh 25
26 a). j=2 will appear in output b). run time error c). compiler error c EXPLANATION compiler gives error message as " variable j might not have been initialized" Select the best statement that can set int i to Label lab, so that lab can display variable i. Assume; Label lab = new Label(); int i = 100; a). lab.settext(i); b). lab.settext(i.tostring()); c). lab.settext(integer.tostring(i)); d). Integer ii = Integer(i); lab.settext(ii.tostring()); c What will be the output of the following code? //file Test.java class Parent{ int i = 0; void amethod(){system.out.println("in Parent");; Gianeshwar Singh 26
27 class Child extends Parent{ int i = 10; void amethod(){system.out.println("in Child");; public class Test{ public static void main(string[] args){ Parent p = new Child(); Child c; System.out.print("i="+p.i+" "); p.amethod(); c = (Child)p; System.out.print("i="+c.i+" "); c.amethod(); a). i=10 in Child follow by i=0 in Child b). i=10 in Child follow by i=0 in Child c). i=0 in Child follow by i=10 in Child d). i=0 in Child follow by i=0 in Child e). Non of above is correct c what will be the output of the following code. //File Test.java class Parent{ private void amethod(){system.out.println("in Parent");; class Child extends Parent{ void amethod(){system.out.println("in Child");; public class Test{ public static void main(string[] args){ Parent p = new Child(); p.amethod(); Gianeshwar Singh 27
28 a). in Parent will appear in output b). in Child will appear in output c). run time error d). compile error d EXPLANATION compile error message as; amethod() has private access in Parent Return to : Java Programming Hints and Tips Gianeshwar Singh 28
The Sun s Java Certification and its Possible Role in the Joint Teaching Material
The Sun s Java Certification and its Possible Role in the Joint Teaching Material Nataša Ibrajter Faculty of Science Department of Mathematics and Informatics Novi Sad 1 Contents Kinds of Sun Certified
More information1 Shyam sir JAVA Notes
1 Shyam sir JAVA Notes 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write
More informationPoints To Remember for SCJP
Points To Remember for SCJP www.techfaq360.com The datatype in a switch statement must be convertible to int, i.e., only byte, short, char and int can be used in a switch statement, and the range of the
More informationSelected Questions from by Nageshwara Rao
Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)
More informationJava Certification Mock Exam
Java Certification Mock Exam John Hunt Email: john.hunt@jttc.demon.co.uk URL: //www.jttc.demon.co.uk/cert.htm As with any examination technique is an important aspect of the examination process. In most
More information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationpublic class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); }
Question No :1 What is the correct ordering for the import, class and package declarations when found in a Java class? 1. package, import, class 2. class, import, package 3. import, package, class 4. package,
More informationDeclarations and Access Control SCJP tips
Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for
More informationSoftware Development & Education Center. Java Platform, Standard Edition 7 (JSE 7)
Software Development & Education Center Java Platform, Standard Edition 7 (JSE 7) Detailed Curriculum Getting Started What Is the Java Technology? Primary Goals of the Java Technology The Java Virtual
More informationCHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA
1. JIT meaning a. java in time b. just in time c. join in time d. none of above CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY JAVA 2. After the compilation of the java source code, which file is created
More informationJava for Programmers Course (equivalent to SL 275) 36 Contact Hours
Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the
More informationLanguage Fundamentals Summary
Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationClass, Variable, Constructor, Object, Method Questions
Class, Variable, Constructor, Object, Method Questions http://www.wideskills.com/java-interview-questions/java-classes-andobjects-interview-questions https://www.careerride.com/java-objects-classes-methods.aspx
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationCS/B.TECH/CSE(New)/SEM-5/CS-504D/ OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70 GROUP A. (Multiple Choice Type Question)
CS/B.TECH/CSE(New)/SEM-5/CS-504D/2013-14 2013 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationMobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE
Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE COURSE TITLE JAVA2 FOR PROGRAMMERS COURSE DURATION 14 Hour(s) of Interactive Training COURSE OVERVIEW With the Java2 for Programmers course, anyone
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationCS 231 Data Structures and Algorithms, Fall 2016
CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard
More information1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these. Answer: B
1. Java is a... language. A. moderate typed B. strogly typed C. weakly typed D. none of these 2. How many primitive data types are there in Java? A. 5 B. 6 C. 7 D. 8 3. In Java byte, short, int and long
More informationVARIABLES AND TYPES CITS1001
VARIABLES AND TYPES CITS1001 Scope of this lecture Types in Java the eight primitive types the unlimited number of object types Values and References The Golden Rule Primitive types Every piece of data
More informationBIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic
BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines
More informationDOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS
Chapter 1 : Chapter-wise Java Multiple Choice Questions and Answers Interview MCQs Java Programming questions and answers with explanation for interview, competitive examination and entrance test. Fully
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationB2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More informationGlobalLogic Technical Question Paper
GlobalLogic Technical Question Paper What is the output of the following code when compiled and run? Select two correct answers. public class Question01 { public static void main(string[] args){ int y=0;
More informationIntroduction to Java
Introduction to Java Module 1: Getting started, Java Basics 22/01/2010 Prepared by Chris Panayiotou for EPL 233 1 Lab Objectives o Objective: Learn how to write, compile and execute HelloWorld.java Learn
More informationAgenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda
More informationJava Basic Programming Constructs
Java Basic Programming Constructs /* * This is your first java program. */ class HelloWorld{ public static void main(string[] args){ System.out.println( Hello World! ); A Closer Look at HelloWorld 2 This
More informationSelected Java Topics
Selected Java Topics Introduction Basic Types, Objects and Pointers Modifiers Abstract Classes and Interfaces Exceptions and Runtime Exceptions Static Variables and Static Methods Type Safe Constants Swings
More informationCOMP 250: Java Programming I. Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette
COMP 250: Java Programming I Carlos G. Oliver, Jérôme Waldispühl January 17-18, 2018 Slides adapted from M. Blanchette Variables and types [Downey Ch 2] Variable: temporary storage location in memory.
More informationTools : The Java Compiler. The Java Interpreter. The Java Debugger
Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,
More informationJump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.
Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationJava Overview An introduction to the Java Programming Language
Java Overview An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/
More informationPROGRAMMING FUNDAMENTALS
PROGRAMMING FUNDAMENTALS Q1. Name any two Object Oriented Programming languages? Q2. Why is java called a platform independent language? Q3. Elaborate the java Compilation process. Q4. Why do we write
More informationCS121/IS223. Object Reference Variables. Dr Olly Gotel
CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationIndex COPYRIGHTED MATERIAL
Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes
More informationChapter 1: Introduction to Computers, Programs, and Java
Chapter 1: Introduction to Computers, Programs, and Java 1. Q: When you compile your program, you receive an error as follows: 2. 3. %javac Welcome.java 4. javac not found 5. 6. What is wrong? 7. A: Two
More informationJava Application Development
A Absolute Size and Position - Specifying... 10:18 Abstract Class... 5:15 Accessor Methods...4:3-4:4 Adding Borders Around Components... 10:7 Adding Components to Containers... 10:6 Adding a Non-Editable
More informationComputer Science is...
Computer Science is... Machine Learning Machine learning is the study of computer algorithms that improve automatically through experience. Example: develop adaptive strategies for the control of epileptic
More informationI pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.
Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone
More informationLanguage Features. 1. The primitive types int, double, and boolean are part of the AP
Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are
More informationJump Statements. The keyword break and continue are often used in repetition structures to provide additional controls.
Jump Statements The keyword break and continue are often used in repetition structures to provide additional controls. break: the loop is terminated right after a break statement is executed. continue:
More informationLearning the Java Language. 2.1 Object-Oriented Programming
Learning the Java Language 2.1 Object-Oriented Programming What is an Object? Real world is composed by different kind of objects: buildings, men, women, dogs, cars, etc. Each object has its own states
More informationSpecial Topics: Programming Languages
Lecture #23 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 23 Lecture #23 1 Slide 1 Java: History Spring 1990 April 1991: Naughton, Gosling and Sheridan (
More informationExpressions & Flow Control
Objectives Distinguish between instance and local variables 4 Expressions & Flow Control Describe how instance variables are initialized Identify and correct a Possible reference before assignment compiler
More informationJava Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.
Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationAn overview of Java, Data types and variables
An overview of Java, Data types and variables Lecture 2 from (UNIT IV) Prepared by Mrs. K.M. Sanghavi 1 2 Hello World // HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public
More informationSoftware Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision
Software Practice 1 - Basic Grammar Basic Syntax Data Type Loop Control Making Decision Prof. Hwansoo Han T.A. Minseop Jeong T.A. Wonseok Choi 1 Java Program //package details public class ClassName {
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationClass definition. complete definition. public public class abstract no instance can be created final class cannot be extended
JAVA Classes Class definition complete definition [public] [abstract] [final] class Name [extends Parent] [impelements ListOfInterfaces] {... // class body public public class abstract no instance can
More informationJava Intro 3. Java Intro 3. Class Libraries and the Java API. Outline
Java Intro 3 9/7/2007 1 Java Intro 3 Outline Java API Packages Access Rules, Class Visibility Strings as Objects Wrapper classes Static Attributes & Methods Hello World details 9/7/2007 2 Class Libraries
More informationCS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70
CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 2012 OBJECT ORIENTED PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give their answers
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More information1.Which four options describe the correct default values for array elements of the types indicated?
1.Which four options describe the correct default values for array elements of the types indicated? 1. int -> 0 2. String -> "null" 3. Dog -> null 4. char -> '\u0000' 5. float -> 0.0f 6. boolean -> true
More informationAbout this exam review
Final Exam Review About this exam review I ve prepared an outline of the material covered in class May not be totally complete! Exam may ask about things that were covered in class but not in this review
More informationGetting started with Java
Getting started with Java by Vlad Costel Ungureanu for Learn Stuff Programming Languages A programming language is a formal constructed language designed to communicate instructions to a machine, particularly
More informationUMBC CMSC 331 Final Exam Section 0101 December 17, 2002
0 / 0 1 / 20 UMBC CMSC 331 Final Exam Section 0101 December 17, 2002 Name: Student ID#: 2 / 25 3 / 20 4 / 25 5 / 20 6 /40 7 /40 You will have two hours to complete this closed book exam. We reserve the
More informationComputer Components. Software{ User Programs. Operating System. Hardware
Computer Components Software{ User Programs Operating System Hardware What are Programs? Programs provide instructions for computers Similar to giving directions to a person who is trying to get from point
More informationBirkbeck (University of London) Software and Programming 1 In-class Test Mar 2018
Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationJava Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing
Java Programming MSc Induction Tutorials 2011 Stefan Stafrace PhD Student Department of Computing s.stafrace@surrey.ac.uk 1 Tutorial Objectives This is an example based tutorial for students who want to
More informationIn Java there are three types of data values:
In Java there are three types of data values: primitive data values (int, double, boolean, etc.) arrays (actually a special type of object) objects An object might represent a string of characters, a planet,
More informationCS321 Languages and Compiler Design I. Winter 2012 Lecture 2
CS321 Languages and Compiler Design I Winter 2012 Lecture 2 1 A (RE-)INTRODUCTION TO JAVA FOR C++/C PROGRAMMERS Why Java? Developed by Sun Microsystems (now Oracle) beginning in 1995. Conceived as a better,
More informationCS 180 Final Exam Review 12/(11, 12)/08
CS 180 Final Exam Review 12/(11, 12)/08 Announcements Final Exam Thursday, 18 th December, 10:20 am 12:20 pm in PHYS 112 Format 30 multiple choice questions 5 programming questions More stress on topics
More informationDM550 Introduction to Programming part 2. Jan Baumbach.
DM550 Introduction to Programming part 2 Jan Baumbach jan.baumbach@imada.sdu.dk http://www.baumbachlab.net COURSE ORGANIZATION 2 Course Elements Lectures: 10 lectures Find schedule and class rooms in online
More informationCS 177 Spring 2010 Exam I
CS 177 Spring 2010 Exam I There are 25 multiple choice questions. Each one is worth 4 points. The total score for the exam is 100. Answer the multiple choice questions on the bubble sheet given. Fill in
More informationNested Classes in Java. Slides by: Alon Mishne Edited by: Eran Gilad, Eyal Moscovici April 2013
Nested Classes in Java Slides by: Alon Mishne Edited by: Eran Gilad, Eyal Moscovici April 2013 1 In This Tutorial Explanation of the nested class concept. Access modifiers and nested classes. The types
More informationThe Java language has a wide variety of modifiers, including the following:
PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access
More information3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal
APCS A Midterm Review You will have a copy of the one page Java Quick Reference sheet. This is the same reference that will be available to you when you take the AP Computer Science exam. 1. n bits can
More informationSoftware Practice 1 Basic Grammar
Software Practice 1 Basic Grammar Basic Syntax Data Type Loop Control Making Decision Prof. Joonwon Lee T.A. Jaehyun Song Jongseok Kim (42) T.A. Sujin Oh Junseong Lee (43) 1 2 Java Program //package details
More information3. Java - Language Constructs I
Names and Identifiers A program (that is, a class) needs a name public class SudokuSolver {... 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations,
More informationA Third Look At Java. Chapter Seventeen Modern Programming Languages, 2nd ed. 1
A Third Look At Java Chapter Seventeen Modern Programming Languages, 2nd ed. 1 A Little Demo public class Test { public static void main(string[] args) { int i = Integer.parseInt(args[0]); int j = Integer.parseInt(args[1]);
More informationCSE 8B Final Exam Fall 2015
Name: Tutor: Student ID: Signature: CSE 8B Final Exam Fall 2015 You can rip off the last page and use as scratch paper. Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 Page 9 Page 10 Page 11 Page 12 0
More informationCertified Core Java Developer VS-1036
VS-1036 1. LANGUAGE FUNDAMENTALS The Java language's programming paradigm is implementation and improvement of Object Oriented Programming (OOP) concepts. The Java language has its own rules, syntax, structure
More informationOBJECT ORIENTED PROGRAMMING TYm. Allotted : 3 Hours Full Marks: 70
I,.. CI/. T.cH/C8E/ODD SEM/SEM-5/CS-504D/2016-17... AiIIIII "-AmI u...iir e~ IlAULAKA ABUL KALAM AZAD UNIVERSITY TECHNOLOGY,~TBENGAL Paper Code: CS-504D OF OBJECT ORIENTED PROGRAMMING TYm. Allotted : 3
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationCS11 Java. Fall Lecture 1
CS11 Java Fall 2006-2007 Lecture 1 Welcome! 8 Lectures Slides posted on CS11 website http://www.cs.caltech.edu/courses/cs11 7-8 Lab Assignments Made available on Mondays Due one week later Monday, 12 noon
More informationCSE 142 Su 04 Computer Programming 1 - Java. Objects
Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request
More informationDM550 / DM857 Introduction to Programming. Peter Schneider-Kamp
DM550 / DM857 Introduction to Programming Peter Schneider-Kamp petersk@imada.sdu.dk http://imada.sdu.dk/~petersk/dm550/ http://imada.sdu.dk/~petersk/dm857/ OBJECT-ORIENTED PROGRAMMING IN JAVA 2 Programming
More informationSolutions to Sample JAC444 Midterm Test
Solutions to Sample JAC444 Midterm Test 1-2016 A. Theory (10 marks = 5 marks + 5 marks) 1. When can one implement a deep cloning in Java? see deep cloning lecture 3 2. What are the differences between
More informationWeek 6: Review. Java is Case Sensitive
Week 6: Review Java Language Elements: special characters, reserved keywords, variables, operators & expressions, syntax, objects, scoping, Robot world 7 will be used on the midterm. Java is Case Sensitive
More informationJava Review Outline. basics exceptions variables arrays modulo operator if statements, booleans, comparisons loops: while and for
Java Review Outline basics exceptions variables arrays modulo operator if statements, booleans, comparisons loops: while and for Java basics write a simple program, e.g. hello world http://www2.hawaii.edu/~esb/2017fall.ics211/helloworl
More informationObject Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.
CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java
More information2 rd class Department of Programming. OOP with Java Programming
1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationTraining topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives
Training topic: OCPJP (Oracle certified professional Java programmer) or SCJP (Sun certified Java programmer) Content and Objectives 1 Table of content TABLE OF CONTENT... 2 1. ABOUT OCPJP SCJP... 4 2.
More informationB2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA
B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE
More informationCSC Java Programming, Fall Java Data Types and Control Constructs
CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationCONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13
CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling
More informationWhat did we talk about last time? Course overview Policies Schedule
Week 1 - Wednesday What did we talk about last time? Course overview Policies Schedule The book talks about stuff that you know pretty well as Java programmers I just want to talk about a few issues
More informationTypes, Values and Variables (Chapter 4, JLS)
Lecture Notes CS 141 Winter 2005 Craig A. Rich Types, Values and Variables (Chapter 4, JLS) Primitive Types Values Representation boolean {false, true} 1-bit (possibly padded to 1 byte) Numeric Types Integral
More information