The document discusses various Java code snippets that test different aspects of conditional expressions and data types in Java. It provides the code snippets, expected output, and in some cases explains why the expected output is what it is based on Java's rules for determining the type of a conditional expression.
This document discusses F# and FParsec. It provides examples of parsing expressions in FParsec using lazy evaluation and references, as opposed to NParsec which uses bindings. FParsec allows defining recursive parsers in a natural way in F#.
Here I link up up some very useful material by Robert Norris (@tpolecat) and Martin Odersky (@odersky) to introduce Monad laws and reinforce the importance of checking the laws. E.g. while Option satisfies the laws, Try is not a lawful Monad: it trades the left identity law for the bullet-proof principle.
* ERRATA *
1) on the first slide the Kleisli composition signature appears three times, but one of the occurrences is incorrect in that it is (>=>)::(a->mb)->(b->mb)->(a->mc) whereas is should be (>=>)::(a->mb)->(b->mc)->(a->mc) - thank you Jules Ivanic.
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell.
See how lazy evaluation and function strictness affect left and right folds in Haskell.
Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold.
This version eliminates some minor imperfections and corrects the following two errors:
slide 15: "as sharing is required" should be "as sharing is not required"
slide 43: 푠푓표푙푑푙 (⊕) 푎 should be 푠푓표푙푑푙 (⊕) 푒
Understand the expression problem
See Haskell and Scala code illustrating the problem
Learn how FP typeclasses can be used to solve the problem
See the Haskell solution to the problem and a translation into Scala
Part 2
Complete Information till 2D arrays. In this slides you can also find information about loops and control decision....
Best slides for beginners who wants to learn about C programming language..
First part of this presentation explains basics and advantages of using functional programming approaches with lambda calculus.
Second part of this presentation explains how can we use lambda calculus in C# 3.0
The document provides an introduction to the CLIPS expert system shell. It discusses CLIPS' components like facts, rules, and the inference engine. It explains how CLIPS uses forward chaining to match facts to rules and fire actions. The objectives are to understand rule-based expert system concepts and apply them using CLIPS.
The document discusses various Java operators including assignment, arithmetic, relational, logical, bitwise, and shift operators. It provides examples of using each operator type on primitive data types like int and boolean. Key points include:
- Assignment (=), arithmetic (+ - * / %), relational (>, <, ==, !=), logical (&&, ||, !) and bitwise (& | ^ ~) operators in Java.
- Implicit type promotions and casts that occur with arithmetic and relational operators.
- Short-circuit evaluation behavior of logical && and || operators.
- Using shift operators (<< >> >>>) to manipulate bits in binary representations of integers.
The document discusses different parameter passing techniques in programming languages, including pass by value, pass by reference, and pass by result/value-result. It provides examples in languages like C, C++, Java, C#, Pascal, Ada to illustrate how each technique works and the differences between them. It also covers topics like parameter modes (in, out, in-out), parameter arrays, and variable arguments.
This document contains sample questions and explanations for the OCP Java SE 8 exam related to lambda expressions and functional interfaces. It includes multiple choice questions testing knowledge of valid lambda expression syntax, lambda behavior and scoping, and proper usage of the @FunctionalInterface annotation. The explanations provide detailed reasoning for the correct answers and why the other options are incorrect.
The Ring programming language version 1.5.3 book - Part 35 of 184
The document provides documentation on various functions available in the Ring programming language standard library (stdlib). It describes functions for generating permutations, reading lines from a file, finding substrings, changing substrings, sleeping, checking if a file is the main source file, checking if a directory exists, making directories, getting file sizes, trimming strings, getting the epoch time, executing system commands, listing all files in a folder, and more. It also provides details on classes in the stdlib like the String, List, Stack, Queue, HashTable, Tree, Math, DateTime, File, and other classes along with their methods.
The Functional Programming Triad of Map, Filter and Fold
This slide deck is my homage to SICP, the book which first introduced me to the Functional Programming triad of map, filter and fold.
It was during my Computer Science degree that a fellow student gave me a copy of the first edition, not long after the book came out.
I have not yet come across a better introduction to these three functions.
The upcoming slides are closely based on the second edition of the book, a free online copy of which can be found here:
https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html.
Download for original image quality.
Errata:
slide 20: the Clojure map function is in fact the Scheme one repeated - see code below for correction.
Scheme code: https://github.com/philipschwarz/the-fp-triad-of-map-filter-and-fold-scheme
Clojure code: https://github.com/philipschwarz/the-fp-triad-of-map-filter-and-fold-clojure
Scope graphs are used to represent the binding information in programs. They provide a language-independent representation of name resolution that can be used to conduct and represent the results of name resolution. Separating the representation of resolved programs from the declarative rules that define name binding allows language-independent tooling to be developed for name resolution and other tasks.
1) The document discusses parsing methods for context-free grammars including top-down and bottom-up approaches. Top-down parsing starts with the start symbol and works towards the leaves, while bottom-up parsing begins at the leaves and works towards the root.
2) Key aspects of parsing covered include left recursion elimination, left factoring, shift-reduce parsing which uses a stack and parsing table, and constructing parse trees from the parsing process.
3) The output of parsers can include parse sequences, parse trees, and abstract syntax trees which abstract away implementation details.
This document provides an overview of the Character class in Java, including how to create Character objects from primitive char values, common character methods like isLetter() and toUpperCase(), escape sequences, and examples of using Character class methods. Character class methods allow checking properties of characters, converting between cases, and boxing/unboxing primitive char values. The document also shares code snippets demonstrating the use of these Character class features in Java programs.
I am Blake H. I am a Software Construction Assignment Expert at programminghomeworkhelp.com. I hold a PhD. in Programming, Curtin University, Australia. I have been helping students with their homework for the past 10 years. I solve assignments related to Software Construction.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with Software Construction Assignments.
This document discusses F# and FParsec. It provides examples of parsing expressions in FParsec using lazy evaluation and references, as opposed to NParsec which uses bindings. FParsec allows defining recursive parsers in a natural way in F#.
Here I link up up some very useful material by Robert Norris (@tpolecat) and Martin Odersky (@odersky) to introduce Monad laws and reinforce the importance of checking the laws. E.g. while Option satisfies the laws, Try is not a lawful Monad: it trades the left identity law for the bullet-proof principle.
* ERRATA *
1) on the first slide the Kleisli composition signature appears three times, but one of the occurrences is incorrect in that it is (>=>)::(a->mb)->(b->mb)->(a->mc) whereas is should be (>=>)::(a->mb)->(b->mc)->(a->mc) - thank you Jules Ivanic.
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Philip Schwarz
(download for best quality slides) Gain a deeper understanding of why right folds over very large and infinite lists are sometimes possible in Haskell.
See how lazy evaluation and function strictness affect left and right folds in Haskell.
Learn when an ordinary left fold results in a space leak and how to avoid it using a strict left fold.
This version eliminates some minor imperfections and corrects the following two errors:
slide 15: "as sharing is required" should be "as sharing is not required"
slide 43: 푠푓표푙푑푙 (⊕) 푎 should be 푠푓표푙푑푙 (⊕) 푒
Understand the expression problem
See Haskell and Scala code illustrating the problem
Learn how FP typeclasses can be used to solve the problem
See the Haskell solution to the problem and a translation into Scala
Part 2
Complete Information till 2D arrays. In this slides you can also find information about loops and control decision....
Best slides for beginners who wants to learn about C programming language..
First part of this presentation explains basics and advantages of using functional programming approaches with lambda calculus.
Second part of this presentation explains how can we use lambda calculus in C# 3.0
The document provides an introduction to the CLIPS expert system shell. It discusses CLIPS' components like facts, rules, and the inference engine. It explains how CLIPS uses forward chaining to match facts to rules and fire actions. The objectives are to understand rule-based expert system concepts and apply them using CLIPS.
The document discusses various Java operators including assignment, arithmetic, relational, logical, bitwise, and shift operators. It provides examples of using each operator type on primitive data types like int and boolean. Key points include:
- Assignment (=), arithmetic (+ - * / %), relational (>, <, ==, !=), logical (&&, ||, !) and bitwise (& | ^ ~) operators in Java.
- Implicit type promotions and casts that occur with arithmetic and relational operators.
- Short-circuit evaluation behavior of logical && and || operators.
- Using shift operators (<< >> >>>) to manipulate bits in binary representations of integers.
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
The document discusses different parameter passing techniques in programming languages, including pass by value, pass by reference, and pass by result/value-result. It provides examples in languages like C, C++, Java, C#, Pascal, Ada to illustrate how each technique works and the differences between them. It also covers topics like parameter modes (in, out, in-out), parameter arrays, and variable arguments.
This document contains sample questions and explanations for the OCP Java SE 8 exam related to lambda expressions and functional interfaces. It includes multiple choice questions testing knowledge of valid lambda expression syntax, lambda behavior and scoping, and proper usage of the @FunctionalInterface annotation. The explanations provide detailed reasoning for the correct answers and why the other options are incorrect.
The Ring programming language version 1.5.3 book - Part 35 of 184Mahmoud Samir Fayed
The document provides documentation on various functions available in the Ring programming language standard library (stdlib). It describes functions for generating permutations, reading lines from a file, finding substrings, changing substrings, sleeping, checking if a file is the main source file, checking if a directory exists, making directories, getting file sizes, trimming strings, getting the epoch time, executing system commands, listing all files in a folder, and more. It also provides details on classes in the stdlib like the String, List, Stack, Queue, HashTable, Tree, Math, DateTime, File, and other classes along with their methods.
The Functional Programming Triad of Map, Filter and FoldPhilip Schwarz
This slide deck is my homage to SICP, the book which first introduced me to the Functional Programming triad of map, filter and fold.
It was during my Computer Science degree that a fellow student gave me a copy of the first edition, not long after the book came out.
I have not yet come across a better introduction to these three functions.
The upcoming slides are closely based on the second edition of the book, a free online copy of which can be found here:
https://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book.html.
Download for original image quality.
Errata:
slide 20: the Clojure map function is in fact the Scheme one repeated - see code below for correction.
Scheme code: https://github.com/philipschwarz/the-fp-triad-of-map-filter-and-fold-scheme
Clojure code: https://github.com/philipschwarz/the-fp-triad-of-map-filter-and-fold-clojure
Declare Your Language: Name ResolutionEelco Visser
Scope graphs are used to represent the binding information in programs. They provide a language-independent representation of name resolution that can be used to conduct and represent the results of name resolution. Separating the representation of resolved programs from the declarative rules that define name binding allows language-independent tooling to be developed for name resolution and other tasks.
The document discusses break and continue statements in C programming. It provides examples of code using break to exit a while loop if a condition is true, and using continue to skip the remaining code in a loop iteration and continue with the next iteration if a condition is true. The examples demonstrate using break and continue with while and for loops to check if a number is prime or to print only numbers divisible by 5 from 1 to 50.
Expression trees is an obscure, although very interesting feature in .NET. Most people probably think of it as something synonymous with object-relational mapping frameworks, but despite being its most common use case, it’s not the only one. There are a lot of creative things you can do with expression trees, including code generation, transpilation, metaprogramming, and more. During this talk, I will explain what this feature really is about and guide you through some examples where it provides real-life benefits.
We'll talk about:
What is an expression tree
How to compile code at runtime
How to make reflection faster
How to implement generic operators
How to turn DSLs into expression trees
How to make metaprogramming type-safe
How to translate a lambda into a different language...and more
This document provides tips for optimizing a LinkedIn profile to become a "LinkedIn ninja". It recommends customizing the headline, photo, status, summary, and specialties sections to focus on thought leadership, personal branding, and generating organic traffic. It emphasizes engaging with others on LinkedIn through events, conversations, and connections to build influence and visibility.
Mobile app development 12 13 y1 ict ssp l17 revMiles Berry
We look at some examples of mobile phone use within the curriculum. We consider issues raised by pupils’ access to personal technology. You experiment with Google’s App Inventor toolkit, creating a simple game for an Android handset.
Army Emergency Relief (AER) is a private nonprofit organization that provides emergency financial assistance to soldiers, their families, and survivors. It was founded in 1942 to help the army take care of its own. AER is governed by a board of managers and provides over $1.3 billion in assistance through programs like interest-free loans, grants, and educational scholarships. It is funded through an annual campaign of soldier donations as well as loan repayments so that soldiers can continue to help fellow soldiers.
Social Business Imperative Women's President OrganizationLiz Bullock
Liz Brown Bullock, Director of Social Media & Community, Dell, presents social business landscape and ten tips on how women owned businesses should be strategically using social to be more effective. Presented at Women’s President Organization in Dallas, Tx on May 1st, 2013
What do YOU have to do to become an Innovator?Uninstall.io
How did disruptive innovators like Steve Jobs come up with those brilliant ideas? How do YOU come up with (almost as) brilliant insights. This graphic tells you how!
Smartphones have become the main mobile device of many and are as important as wallet and keys. Trends on smartphones and tablets in the enterprise (Androids, iPads and iPhones), technology distractions, how many workers use their personal devices at work, future of BlackBerry and Microsoft phones and more. For the most recent report: http://bit.ly/104g0OY
The EUN Learning Resource Exchange (LRE)David Massart
The document provides information about the Learning Resource Exchange (LRE), a catalogue of open educational resources for K-12 education in Europe managed by European Schoolnet. The LRE aims to provide access to over 200,000 resources. It outlines the history and goals of the LRE, describes how it is governed, and discusses future plans to improve discovery of resources through linking them to curriculum standards in various European countries in a machine-readable way. This would allow teachers and students to more easily find resources that are relevant to their curricula.
The document discusses various programming concepts in C# such as data types, control flow statements like if/else, switch, loops (for, while, do-while), methods for generating random numbers, and examples of programming problems involving calculations, patterns, and simulating dice rolls. Random numbers can be generated using the Random class, control structures conditionally execute blocks of code, and loops iterate code for a set number of repetitions.
The document discusses various programming concepts in C# such as random number generation, Boolean expressions, control statements like if/else, switch, for, while and do-while loops. It also covers nested loops, break and continue statements, and provides examples of problems that can be solved using these programming constructs like generating random numbers, printing patterns, and simulating dice rolls.
The document provides an outline of topics for a C/C++ tutorial, including a "Hello World" program, data types, variables, operators, conditionals, loops, arrays, strings, functions, pointers, command-line arguments, data structures, and memory allocation. It gives examples and explanations of key concepts in C/C++ programming.
The document provides an overview of key concepts in the C# programming language including variables and data types, arrays, conditional logic, loops, methods, parameters, and delegates. It discusses basic syntax, operators, and how to perform common tasks like type conversions and working with dates and strings. The goal is to give readers enough information to get started with C# as well as refer back to for language details while working through ASP.NET examples.
This document provides an overview of key concepts in the Java programming language, including:
- Java is an object-oriented language that is simpler than C++ and supports features like platform independence.
- The Java development environment includes tools for compiling, debugging, and running Java programs.
- Java programs work with basic data types like int and double, as well as user-defined classes, variables, and arrays.
- The document explains operators, control structures, formatting output, and the basics of classes and objects in Java.
This document discusses conditional execution and if/else statements in Java. It covers the basic if statement, if/else statement, relational operators, nested if/else structures, and misuse of if statements. It also discusses logical operators, evaluating logical expressions, factoring if/else code, methods that return values based on if/else conditions, and ensuring all code paths return a value. Finally, it discusses cumulative algorithms using if/else structures and loops to calculate running sums and products.
The document summarizes several Java 5 features including generics, enhanced for loops, autoboxing/unboxing, typesafe enums, varargs, static imports, and annotations. It provides examples and explanations of each feature.
This document discusses selection statements in Java including if, if-else, nested if, and switch statements. It provides examples of syntax and usage for each statement type. Key topics covered include boolean expressions, relational operators, short-circuit evaluation, operator precedence, comparing objects, and the semantics of == versus equals().
Oracle Certified Associate (OCA) Java SE 8 Programmer II (1Z0-809) - Practice...Udayan Khattry
Assess your preparation with these Practice Test Questions with Explanation. Questions are Extracted from Highest Rated Course on Udemy which has helped a lot of students to pass the exam with good score.
500+ multiple choice questions with explanation to assess Oracle Certified Associate, Java SE 8 Programmer II preparation.
Highest Rated course on UDEMY
Read the students success stories at:
https://udayankhattry.com/ocp/
Enroll now to receive maximum discount on the course ie. for just $9.99 or ₹640.00, click the link below- https://www.udemy.com/java-ocp/?couponCode=UDAYANKHATTRY.COM
To avail maximum discount on all courses visit: www.udayankhattry.com
This document discusses optimizing C# code for speed, maintainability, and flexibility. It provides tips for using profilers to optimize for speed, establishing coding standards to improve maintainability, and refactoring code. Exceptions, allocation in loops, string concatenation, and validating enum values are discussed as examples of code that could be optimized. Guidelines are provided around using exceptions, GC.Collect, and designing enums.
This document provides an outline and notes from a lecture on types, methods, and conditionals in Java. It introduces boolean, int, double, and String types, as well as variables, operators, and order of operations. It discusses defining and calling methods, including parameters and return values. It also covers if, else, and else if statements for conditional execution, and comparison operators.
This is my attempt at a look at some of the features of C++11, and more importantly, describing some of the style changes in C++11 that will make programmers more productive and programs more efficient.
Typescript fundamentals document summarized in 3 sentences:
The document discusses Typescript fundamentals including types, classes, interfaces, modules and how to use the Typescript compiler. It explains how Typescript adds type safety and compile time checking to JavaScript by using types for variables, parameters, returns and more. Examples are provided for many Typescript features and how they compile down to equivalent JavaScript.
This document provides an introduction to Java programming concepts including what Java is, how to set up a Java development environment, basic Java code structure, variables, data types, arithmetic operations, conditional statements, loops, and getting user input. It covers elementary Java topics through examples and explanations. Key points include how to write, compile and run a simple Java program that prints "Hello World", how to declare and use variables of different data types, the different conditional statements (if, if-else, if-else-if-else), looping constructs (while, do-while, for), and taking user input using the Scanner class.
Asynchronous operations are getting more and more popular. To the point that we are getting frameworks and environments revolving strictly around that concept. Boost.ASIO, Twisted and node.js are notable example. We will not explore that area. We will focus on techniques for making asynchronous more readable. We will present different currently used solutions. At the end we will introduce coroutines and explain the concept. We will show how these can be integrated with asynchronous code and what we benefit from using coroutines in asynchronous code.
This presentation provides an overview of key topics in Java class design; also covers best practices/tips and quiz questions. Based on our OCP 8 book.
The C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.
The C is the most widely used computer language, it keeps fluctuating at number one scale of popularity along with Java programming language, which is also equally popular and most widely used among modern software programmers.
This talk is an introduction about technical aspects of how payment cards function, what technical protocols are involved and what are implementation complexities in a typical payments project. You will learn about concepts like Authorisation and Clearing, Tokenization and know about novelties in the payment world, which will affect consumers in the nearest future.
Как построить свой фреймворк для автотестов?Dmitry Buzdin
Мы пройдемся по всем основным блокам построения тестового фреймворка и тому, как они связаны между собой. Вы научитесь собирать свое решение по автоматизации из библиотек с открытым кодом и делать так, чтобы они дополняли друг друга.
The document discusses how to grow microservices from a monolithic architecture using a staged approach. It recommends starting with a modular monolith broken into bounded context modules that can be deployed and tested independently. These modules can then be upgraded to independent microservices by separating databases, exposing APIs, and moving to an eventual consistency model. The process should be iterative, allowing code to be refactored and services extracted gradually based on factors like scalability needs and usage patterns. Practical advice includes API-first design, avoiding reusable frameworks, using schema per bounded context, and embracing testing and devops best practices.
How to Build Your Own Test Automation Framework?Dmitry Buzdin
Even though there are plenty of open source tools on the market every company needs to put them together and create a test automation framework on top. Best practices of doing that are quite well-known in industry and it is important to learn them before building your own framework. We will go through the core building blocks of test automation frameworks and how they are playing together. You will learn how to assemble your test automation toolchain out of open source libraries and how to integrate them together. The session will be heavily biased towards Java platform.
Big Data Processing Using Hadoop InfrastructureDmitry Buzdin
The document discusses using Hadoop infrastructure for big data processing. It describes Intrum Justitia SDC, which has data across 20 countries in various formats and a high number of data objects. Hadoop provides solutions like MapReduce and HDFS for distributed storage and processing at scale. The Hadoop ecosystem includes tools like Hive, Pig, HBase, Impala and Oozie that help process and analyze large datasets. Examples of using Hadoop with Java and integrating it into development environments are also included.
The document provides an overview of using Flyway and JOOQ together to manage database migrations and generate Java objects from database schemas. Flyway is used to run SQL scripts for schema migrations, while JOOQ generates Java classes that correspond to database tables and can be used to write type-safe SQL queries. Examples are given of using JOOQ to build queries, fetch results in various formats, perform CRUD operations on records, and integrate Flyway and JOOQ into build systems like Gradle.
This document discusses best practices for developing useful APIs. It recommends treating all reusable code as an API and following principles like using minimal dependencies and packaging code appropriately. It also provides examples of API design patterns at the module, class, and method level, such as using dependency injection, builder patterns, and exception handling conventions. The goal is to make APIs easy to read, use, extend, and hard to misuse by learning from open source projects and following trends in API design.
This document summarizes some of the new features introduced in Java 8, including streams, lambda expressions, default methods, and date/time API changes. It discusses streams in more detail, covering stream operations like filter, map, distinct, and collect. It also covers new features like Optional for returning absent/present values, annotations for null checks, parallel array sorting, and concurrency utilities.
This document provides an overview of a Dart workshop that teaches Dart fundamentals and building full-stack Dart applications. The workshop is divided into five parts that cover Hello World examples, integrating Google Maps, dynamic HTML, adding a server backend, and connecting to MongoDB. Each part includes tasks to complete and concepts to learn, such as the Dart project structure, writing unit tests, manipulating the DOM, making HTTP requests, and using the MongoDB Dart driver. The conclusion discusses why Dart may be better than JavaScript and considers if Dart has the potential to be the future for web development.
This document discusses how Redis can be used to solve various data and application scenarios for a social Q&A platform. It describes 6 scenarios including using Redis strings for counters, Redis lists for a message queue, Redis hashes for user activity tracking, Redis bits for feature flags, Redis sorted sets for a social wall, and Redis pub/sub for real-time monitoring. It provides examples of how Redis data structures map to each use case and discusses capabilities like performance, scalability and data consistency.
This document discusses refactoring Java code to Clojure using macros. It provides examples of refactoring Java code that uses method chaining to equivalent Clojure code using the threading macros (->> and -<>). It also discusses other Clojure features like type hints, the doto macro, and polyglot projects using Leiningen.
This document discusses ways to introduce functional programming concepts into Java code using existing Java 8 features, third-party libraries like Guava and LambdaJ, and by implementing common functional patterns and data structures yourself. It provides examples of using higher order functions, pure functions, recursion, and currying in Java code. It also summarizes capabilities of the Guava and LambdaJ libraries for functional programming in Java.
This document discusses continuous delivery, which is an agile methodology for frequently delivering incremental software changes to users. It involves fully automating the build, deployment, testing and release processes through a deployment pipeline. This reduces costs and risks while ensuring that quality software is delivered to users quickly. The document outlines various goals and best practices of continuous delivery, such as automating everything possible, testing excessively, and avoiding anti-patterns like code freezes or manual deployments. It also discusses tools that can help with continuous delivery and adopting this approach.
This document provides an introduction to infrastructure as code and DevOps. It discusses how infrastructure complexity has increased over time from mainframes to multi-tier applications to cloud computing. It also covers how separate development and operations teams can be merged into a unified DevOps team. Infrastructure as code is introduced as treating infrastructure like code by automating server provisioning, configuration, and changes using tools like Puppet, allowing infrastructure to be version controlled and changes to be tested. This enables continuous delivery of infrastructure updates alongside application code changes.
The document discusses various issues that can occur in multi-threaded applications and how thread dumps can help identify and diagnose them. It describes problems that can arise from I/O blocking, inefficient algorithms, lock contention, deadlocks, and non-thread-safe code. It provides examples like a HashMap causing 100% CPU usage. It also covers thread dump formats, tools for analyzing thread dumps, and questions that thread dumps may help answer about sporadic application behavior and performance problems.
2. Many thanks..... James Gosling and Sun Microsystems for Java Google for TechTalks video Joshua Bloch for Java Puzzlers
3. Long Division @Test public void LongDivision() { final long MICROS_PER_DAY =24*60*60*1000*1000; final long MILLIS_PER_DAY =24*60*60*1000; long res =( MICROS_PER_DAY / MILLIS_PER_DAY ); assertEquals(1000, res ); } Result: 1000 - Ok or Error?
4. Long Division @Test public void LongDivision() { final long MICROS_PER_DAY =24*60*60*1000*1000; final long MILLIS_PER_DAY =24*60*60*1000; long res = ( MICROS_PER_DAY / MILLIS_PER_DAY ); assertEquals(1000, res); } Result: Ok or Error , because res is 5 . Why?
5. Long Division @Test public void LongDivision() { final long MICROS_PER_DAY =24L*60*60*1000*1000; final long MILLIS_PER_DAY =24L*60*60*1000; long res = ( MICROS_PER_DAY / MILLIS_PER_DAY ); assertEquals(1000, res); } Result: Ok , because res is 1000 .
9. What is the size? @Test public void whatIsTheSize() { Set<Short> list = new HashSet<Short>(); for (short i = 0; i<100; i++ ) { list.add(i); list.remove( i - 1); } assertEquals(1,list.size()); } Result: 1 ?
10. What is the size? @Test public void whatIsTheSize() { Set<Short> list = new HashSet<Short>(); for (short i = 0; i<100; i++ ) { list.add(i); list.remove( i - 1); } assertEquals(1,list.size()); } Result: 100 . Why????
11. What is size [2] ? final String[] URL_NAMES = { "http://www.google.com", "http://www.google.lv", "http://google.com", }; @Test public void urlSet() throws MalformedURLException { Set<URL> favorites = new HashSet<URL>(); for(String name: URL_NAMES) { favorites.add( new URL(name)); } assertEquals( 3 ,favorites.size()); } What is size, 3 ?
12. What is size [2] ? final String[] URL_NAMES = { "http://www.google.com", "http://www.google.lv", "http://google.com", }; @Test public void urlSet() throws MalformedURLException { Set<URL> favorites = new HashSet<URL>(); for(String name: URL_NAMES) { favorites.add( new URL(name)); } assertEquals( 3 ,favorites.size()); } Size is 1 . Why???
13. Evil class DB { private static final DB db = new DB(); public static DB getDB(){ return db; } private static final String URL=System.getProperty("url"); private static final String USR=System.getProperty("usr"); private static final String PSW=System.getProperty("psw"); private DB(){ this.connection = URL+":"+USR+":"+PSW; } private String connection; public String getConnection() { return connection; } } DB db = DB.getDB(); System.out.println(db.getConnection()); What is result?
14. Evil class DB { private static final DB db = new DB(); public static DB getDB(){ return db; } private static final String URL=System.getProperty("url"); private static final String USR=System.getProperty("usr"); private static final String PSW=System.getProperty("psw"); private DB(){ this.connection = URL+":"+USR+":"+PSW; } private String connection; public String getConnection() { return connection; } } DB db = DB.getDB(); System.out.println(db.getConnection()); null:null:null
15. "Hamlet" @Test public void hamlet(){ Random rnd = new Random(); boolean toBe = rnd.nextBoolean(); Number result = (toBe || !toBe) ? new Integer(3): new Float(1); System.out.println(result); } (a) 3 (b) 1.0 (c) Throws exception (d) None of the above
16. "Hamlet" @Test public void hamlet(){ Random rnd = new Random(); boolean toBe = rnd.nextBoolean(); Number result = (toBe || !toBe) ? new Integer(3): new Float(1); System.out.println(result); } (a) 3 (b) 1.0 (c) Throws exception (d) None of the above 3.0 , Why???
17. "Hamlet" @Test public void hamlet(){ Random rnd = new Random(); boolean toBe = rnd.nextBoolean(); Integer i = new Integer(3); Float f = new Float(1); Number result = (toBe || !toBe) ? i : f; System.out.println( result == i); } (a) true (b) false (c) Throws exception (d) None of the above
18. "Hamlet" @Test public void hamlet(){ Random rnd = new Random(); boolean toBe = rnd.nextBoolean(); Integer i = new Integer(3); Float f = new Float(1); Number result = (toBe || !toBe) ? i : f; System.out.println( result == i); } (a) true (b) false (c) Throws exception (d) None of the above
19. The type of a conditional expression is determined as follows: If the second and third operands have the same type (which may be the null type), then that is the type of the conditional expression. If one of the second and third operands is of type boolean and the type of the other is of type Boolean, then the type of the conditional expression is boolean. If one of the second and third operands is of the null type and the type of the other is a reference type, then the type of the conditional expression is that reference type. Otherwise, if the second and third operands have types that are convertible (§5.1.8) to numeric types, then there are several cases: If one of the operands is of type byte or Byte and the other is of type short or Short, then the type of the conditional expression is short. If one of the operands is of type T where T is byte, short, or char, and the other operand is a constant expression of type int whose value is representable in type T , then the type of the conditional expression is T . If one of the operands is of type Byte and the other operand is a constant expression of type int whose value is representable in type byte, then the type of the conditional expression is byte. If one of the operands is of type Short and the other operand is a constant expression of type int whose value is representable in type short, then the type of the conditional expression is short. If one of the operands is of type; Character and the other operand is a constant expression of type int whose value is representable in type char, then the type of the conditional expression is char. Otherwise, binary numeric promotion (§5.6.2) is applied to the operand types, and the type of the conditional expression is the promoted type of the second and third operands. Note that binary numeric promotion performs unboxing conversion (§5.1.8) and value set conversion (§5.1.13) . Otherwise, the second and third operands are of types S1 and S2 respectively. Let T1 be the type that results from applying boxing conversion to S1 , and let T2 be the type that results from applying boxing conversion to S2 . The type of the conditional expression is the result of applying capture conversion (§5.1.10) to lub(T1, T2) (§15.12.2.7) . Java Language Spesification 15.25