The document summarizes key concepts about objects and primitives in Java including:
1) Objects are stored on the heap while primitives are stored on the stack. Local variable references to objects point to their location on the heap.
2) Mutable objects like StringBuffer can be changed, affecting all references, while immutable objects like String cannot be changed after creation.
3) The == operator checks if two primitives have the same value or if two object references refer to the same object. The equals() method compares the values of objects.
The document discusses JavaScript and why it is misunderstood. It covers how JavaScript is object-oriented despite appearing procedural, uses functions as first-class objects, and has closures. Early versions had bugs and did not respect standards, but modern JavaScript is a full object-oriented language. The document also discusses JavaScript's loose typing, objects and prototypes, performance issues related to interpretation and scope chains, and memory leaks from circular references.
The document summarizes 10 idioms for expressing common programming patterns in Ceylon's type system in a concise and type-safe way. These include functions with multiple outcomes, functions returning null, overloading, multiple return values, spreading tuple returns, unions and intersections of values, distinguishing empty and nonempty iterables, abstracting over function types, and auto-discovering annotated classes. The idioms show how Ceylon's type system allows regaining expressiveness within static typing boundaries compared to languages like Java.
The document discusses the increasing commercialization of education in India. It notes that universities are treating students as customers and focusing on turning a profit. This has led to misleading promotions and a lack of quality in education. There is a need to make universities and their staff legally accountable and increase regulation of fees and infrastructure standards. Students should be made aware of their rights as consumers of educational services so they can fight exploitation. Overall the document argues that while privatization of education can increase access, it is currently being used to exploit students for profit rather than improve education quality.
We build robots and compete in various robotics competitions. The robotics club builds and programs robots, and occasionally holds internal competitions to challenge members. Members meet every Tuesday after school to build robots, program them, and prepare for upcoming competitions like the National Junior Robotics Competition and underwater robotics tournaments. The club provides a fun and engaging extracurricular activity focused on building robots.
1. Ethics in business contributes to customer satisfaction by helping salespeople provide customers with products that meet their needs rather than focusing solely on profit. This increases customer enjoyment and satisfaction with the seller. Providing accurate product information also builds customer trust and reliability in the company. Resolving customer issues satisfactorily further increases their satisfaction.
2. Studying business ethics is important for several reasons. It helps businesses avoid legal issues and scandals that can damage their image. It also protects the business and attracts partners and customers who prefer to work with ethical companies. Learning ethics can curb greed and help entrepreneurs make wise decisions that benefit both the business and customers over the long run. This leads to increased profits, productivity and
The document discusses various Java string concepts:
1. Java strings are immutable sequences of characters that are objects of the String class. The StringBuffer class can be used to modify strings.
2. Common string methods include length(), charAt(), compareTo(), concat(), and substring().
3. The StringBuffer class represents mutable strings and defines methods like append(), insert(), delete(), and replace() to modify the string content.
4. Enumerated types in Java can be defined using the enum keyword to represent a fixed set of constants, like the days of the week.
The document discusses JavaScript and why it is misunderstood. It covers how JavaScript is object-oriented despite appearing procedural, uses functions as first-class objects, and has closures. Early versions had bugs and did not respect standards, but modern JavaScript is a full object-oriented language. The document also discusses JavaScript's loose typing, objects and prototypes, performance issues related to interpretation and scope chains, and memory leaks from circular references.
The document summarizes 10 idioms for expressing common programming patterns in Ceylon's type system in a concise and type-safe way. These include functions with multiple outcomes, functions returning null, overloading, multiple return values, spreading tuple returns, unions and intersections of values, distinguishing empty and nonempty iterables, abstracting over function types, and auto-discovering annotated classes. The idioms show how Ceylon's type system allows regaining expressiveness within static typing boundaries compared to languages like Java.
The document discusses the increasing commercialization of education in India. It notes that universities are treating students as customers and focusing on turning a profit. This has led to misleading promotions and a lack of quality in education. There is a need to make universities and their staff legally accountable and increase regulation of fees and infrastructure standards. Students should be made aware of their rights as consumers of educational services so they can fight exploitation. Overall the document argues that while privatization of education can increase access, it is currently being used to exploit students for profit rather than improve education quality.
We build robots and compete in various robotics competitions. The robotics club builds and programs robots, and occasionally holds internal competitions to challenge members. Members meet every Tuesday after school to build robots, program them, and prepare for upcoming competitions like the National Junior Robotics Competition and underwater robotics tournaments. The club provides a fun and engaging extracurricular activity focused on building robots.
1. Ethics in business contributes to customer satisfaction by helping salespeople provide customers with products that meet their needs rather than focusing solely on profit. This increases customer enjoyment and satisfaction with the seller. Providing accurate product information also builds customer trust and reliability in the company. Resolving customer issues satisfactorily further increases their satisfaction.
2. Studying business ethics is important for several reasons. It helps businesses avoid legal issues and scandals that can damage their image. It also protects the business and attracts partners and customers who prefer to work with ethical companies. Learning ethics can curb greed and help entrepreneurs make wise decisions that benefit both the business and customers over the long run. This leads to increased profits, productivity and
The document discusses various Java string concepts:
1. Java strings are immutable sequences of characters that are objects of the String class. The StringBuffer class can be used to modify strings.
2. Common string methods include length(), charAt(), compareTo(), concat(), and substring().
3. The StringBuffer class represents mutable strings and defines methods like append(), insert(), delete(), and replace() to modify the string content.
4. Enumerated types in Java can be defined using the enum keyword to represent a fixed set of constants, like the days of the week.
String objects are immutable in Java, so any operation that modifies a String value actually creates a new String object. The StringBuffer and StringBuilder classes provide mutable alternatives to String that have similar methods but do not create new objects with each modification. When a String literal value is used in code, it is stored in the String constant pool to promote reuse of these immutable objects.
String objects in Java are immutable and stored in a string pool to improve performance. The StringBuffer class can be used to create mutable strings that can be modified after creation. It provides methods like append(), insert(), replace(), and delete() to modify the string content. The ensureCapacity() method on StringBuffer is used to reserve enough memory to reduce reallocation as the string is modified.
The document discusses the String class in Java. Some key points:
- Strings are immutable sequences of characters that are objects of type String
- The StringBuffer class can be used to modify strings, as it allows changes to the original string
- Common string methods include length(), charAt(), equals(), concat(), and substring()
- Autoboxing and unboxing allow automatic conversion between primitive types and their corresponding wrapper classes like Integer
This document discusses strings in Java. It explains that strings are immutable sequences of characters that can be represented by the String, StringBuffer, or StringBuilder classes. It covers string literals, the string literal pool, comparing and concatenating strings, useful string methods, and creating mutable strings using StringBuffer. It also discusses string interning and representing objects as strings using the toString() method.
The document discusses the String class in Java and string processing. It covers that strings are immutable sequences of characters, how they are created and stored, and the differences between using the String, StringBuffer, and StringBuilder classes. It also summarizes common string methods and how to compare strings using the == operator, equals() method, and compareTo() method.
This document discusses Java strings and string-related concepts in Java. It covers:
- How strings are implemented as objects in Java
- Creating strings using literals vs. the new keyword
- Common string methods like length(), charAt(), equals(), etc.
- Immutability of strings in Java
- Comparing strings using equals(), ==, and compareTo()
- String concatenation and splitting
- The StringBuffer class for mutable strings
- The StringTokenizer class for breaking strings into tokens
The document provides examples and explanations of key string-related topics in Java like object creation, comparison, mutability, and common methods. It aims to give an overview of working with strings as a
String is an object that represents a sequence of characters. The three main String classes in Java are String, StringBuffer, and StringTokenizer. String is immutable, while StringBuffer allows contents to be modified. Common string methods include length(), charAt(), substring(), indexOf(), and equals(). The StringBuffer class is similar to String but more flexible as it allows adding, inserting and appending new contents.
StringBuffer allows modification of a string by providing methods to append, insert, replace, and delete portions of the string. It maintains an internal cursor that tracks the current position during these modifications. StringTokenizer breaks a string into tokens based on delimiters and also uses a cursor to iterate over the extracted tokens. Common methods for both classes include nextToken() to return the next token, countTokens() to get the number of remaining tokens, and hasMoreTokens() to check if additional tokens exist.
This document discusses various string processing and manipulation techniques in C#. It defines what a string is, how to create and initialize strings, and how to perform common string operations like comparing, concatenating, searching, extracting substrings, splitting, replacing, trimming, and changing character casing. Examples are provided to demonstrate how to use string methods like IndexOf, Substring, Split, Replace, ToLower, TrimStart and more to manipulate and modify string values in C# applications.
Parabolic antenna alignment system with Real-Time Angle Position FeedbackStevenPatrick17
Introduction
Parabolic antennas are a crucial component in many communication systems, including satellite communications, radio telescopes, and television broadcasting. Ensuring these antennas are properly aligned is vital for optimal performance and signal strength. A parabolic antenna alignment system, equipped with real-time angle position feedback and fault tracking, is designed to address this need. This document delves into the components, design, and implementation of such a system, highlighting its significance and applications.
Importance of Parabolic Antenna Alignment
The alignment of a parabolic antenna directly affects its performance. Even minor misalignments can lead to significant signal loss, which can degrade the quality of the received signal or cause communication failures. Proper alignment ensures that the antenna's focal point is accurately directed toward the signal source, maximizing the antenna's gain and efficiency. This precision is especially crucial in applications like satellite communications, where the antenna must track geostationary satellites with high accuracy.
Components of a Parabolic Antenna Alignment System
A parabolic antenna alignment system typically includes the following components:
Parabolic Dish: The primary reflector that collects and focuses incoming signals.
Feedhorn and Low Noise Block (LNB): Positioned at the dish's focal point to receive signals.
Stepper or Servo Motors: Adjust the azimuth (horizontal) and elevation (vertical) angles of the antenna.
Microcontroller (e.g., Arduino, Raspberry Pi): Processes sensor data and controls the motors.
Potentiometers: Provide feedback on the antenna's current angle positions.
Fault Detection Sensors: Monitor for potential faults such as cable discontinuities or LNB failures.
Control Software: Runs on the microcontroller, handling real-time processing and decision-making.
Real-Time Angle Position Feedback
Real-time feedback on the antenna's angle position is essential for maintaining precise alignment. This feedback is typically provided by potentiometers or rotary encoders, which continuously monitor the azimuth and elevation angles. The microcontroller reads this data and adjusts the motors accordingly to keep the antenna aligned with the signal source.
Fault Tracking in Antenna Alignment Systems
Fault tracking is vital for the reliability and performance of the antenna system. Common faults include cable discontinuities, LNB malfunctions, and motor failures. Sensors integrated into the system can detect these faults and either notify the user or initiate corrective actions automatically.
Design and Implementation
1. Parabolic Dish and Feedhorn
The parabolic dish is designed to reflect incoming signals to a focal point where the feedhorn and LNB are located. The dish's size and shape depend on the specific application and frequency range.
2. Motors and Position Control
Stepper motors or servo motors are used to control the azimuth and elevation of
LinkedIn for Your Job Search June 17, 2024Bruce Bennett
This webinar helps you understand and navigate your way through LinkedIn. Topics covered include learning the many elements of your profile, populating your work experience history, and understanding why a profile is more than just a resume. You will be able to identify the different features available on LinkedIn and where to focus your attention. We will teach how to create a job search agent on LinkedIn and explore job applications on LinkedIn.
We recently hosted the much-anticipated Community Skill Builders Workshop during our June online meeting. This event was a culmination of six months of listening to your feedback and crafting solutions to better support your PMI journey. Here’s a look back at what happened and the exciting developments that emerged from our collaborative efforts.
A Gathering of Minds
We were thrilled to see a diverse group of attendees, including local certified PMI trainers and both new and experienced members eager to contribute their perspectives. The workshop was structured into three dynamic discussion sessions, each led by our dedicated membership advocates.
Key Takeaways and Future Directions
The insights and feedback gathered from these discussions were invaluable. Here are some of the key takeaways and the steps we are taking to address them:
• Enhanced Resource Accessibility: We are working on a new, user-friendly resource page that will make it easier for members to access training materials and real-world application guides.
• Structured Mentorship Program: Plans are underway to launch a mentorship program that will connect members with experienced professionals for guidance and support.
• Increased Networking Opportunities: Expect to see more frequent and varied networking events, both virtual and in-person, to help you build connections and foster a sense of community.
Moving Forward
We are committed to turning your feedback into actionable solutions that enhance your PMI journey. This workshop was just the beginning. By actively participating and sharing your experiences, you have helped shape the future of our Chapter’s offerings.
Thank you to everyone who attended and contributed to the success of the Community Skill Builders Workshop. Your engagement and enthusiasm are what make our Chapter strong and vibrant. Stay tuned for updates on the new initiatives and opportunities to get involved. Together, we are building a community that supports and empowers each other on our PMI journeys.
Stay connected, stay engaged, and let’s continue to grow together!
About PMI Silver Spring Chapter
We are a branch of the Project Management Institute. We offer a platform for project management professionals in Silver Spring, MD, and the DC/Baltimore metro area. Monthly meetings facilitate networking, knowledge sharing, and professional development. For more, visit pmissc.org.
LinkedIn Strategic Guidelines for June 2024Bruce Bennett
LinkedIn is a powerful tool for networking, researching, and marketing yourself to clients and employers. This session teaches strategic practices for building your LinkedIn internet presence and marketing yourself. The use of # and @ symbols is covered as well as going mobile with the LinkedIn app.
String objects are immutable in Java, so any operation that modifies a String value actually creates a new String object. The StringBuffer and StringBuilder classes provide mutable alternatives to String that have similar methods but do not create new objects with each modification. When a String literal value is used in code, it is stored in the String constant pool to promote reuse of these immutable objects.
String objects in Java are immutable and stored in a string pool to improve performance. The StringBuffer class can be used to create mutable strings that can be modified after creation. It provides methods like append(), insert(), replace(), and delete() to modify the string content. The ensureCapacity() method on StringBuffer is used to reserve enough memory to reduce reallocation as the string is modified.
The document discusses the String class in Java. Some key points:
- Strings are immutable sequences of characters that are objects of type String
- The StringBuffer class can be used to modify strings, as it allows changes to the original string
- Common string methods include length(), charAt(), equals(), concat(), and substring()
- Autoboxing and unboxing allow automatic conversion between primitive types and their corresponding wrapper classes like Integer
This document discusses strings in Java. It explains that strings are immutable sequences of characters that can be represented by the String, StringBuffer, or StringBuilder classes. It covers string literals, the string literal pool, comparing and concatenating strings, useful string methods, and creating mutable strings using StringBuffer. It also discusses string interning and representing objects as strings using the toString() method.
The document discusses the String class in Java and string processing. It covers that strings are immutable sequences of characters, how they are created and stored, and the differences between using the String, StringBuffer, and StringBuilder classes. It also summarizes common string methods and how to compare strings using the == operator, equals() method, and compareTo() method.
This document discusses Java strings and string-related concepts in Java. It covers:
- How strings are implemented as objects in Java
- Creating strings using literals vs. the new keyword
- Common string methods like length(), charAt(), equals(), etc.
- Immutability of strings in Java
- Comparing strings using equals(), ==, and compareTo()
- String concatenation and splitting
- The StringBuffer class for mutable strings
- The StringTokenizer class for breaking strings into tokens
The document provides examples and explanations of key string-related topics in Java like object creation, comparison, mutability, and common methods. It aims to give an overview of working with strings as a
String is an object that represents a sequence of characters. The three main String classes in Java are String, StringBuffer, and StringTokenizer. String is immutable, while StringBuffer allows contents to be modified. Common string methods include length(), charAt(), substring(), indexOf(), and equals(). The StringBuffer class is similar to String but more flexible as it allows adding, inserting and appending new contents.
StringBuffer allows modification of a string by providing methods to append, insert, replace, and delete portions of the string. It maintains an internal cursor that tracks the current position during these modifications. StringTokenizer breaks a string into tokens based on delimiters and also uses a cursor to iterate over the extracted tokens. Common methods for both classes include nextToken() to return the next token, countTokens() to get the number of remaining tokens, and hasMoreTokens() to check if additional tokens exist.
This document discusses various string processing and manipulation techniques in C#. It defines what a string is, how to create and initialize strings, and how to perform common string operations like comparing, concatenating, searching, extracting substrings, splitting, replacing, trimming, and changing character casing. Examples are provided to demonstrate how to use string methods like IndexOf, Substring, Split, Replace, ToLower, TrimStart and more to manipulate and modify string values in C# applications.
Parabolic antenna alignment system with Real-Time Angle Position FeedbackStevenPatrick17
Introduction
Parabolic antennas are a crucial component in many communication systems, including satellite communications, radio telescopes, and television broadcasting. Ensuring these antennas are properly aligned is vital for optimal performance and signal strength. A parabolic antenna alignment system, equipped with real-time angle position feedback and fault tracking, is designed to address this need. This document delves into the components, design, and implementation of such a system, highlighting its significance and applications.
Importance of Parabolic Antenna Alignment
The alignment of a parabolic antenna directly affects its performance. Even minor misalignments can lead to significant signal loss, which can degrade the quality of the received signal or cause communication failures. Proper alignment ensures that the antenna's focal point is accurately directed toward the signal source, maximizing the antenna's gain and efficiency. This precision is especially crucial in applications like satellite communications, where the antenna must track geostationary satellites with high accuracy.
Components of a Parabolic Antenna Alignment System
A parabolic antenna alignment system typically includes the following components:
Parabolic Dish: The primary reflector that collects and focuses incoming signals.
Feedhorn and Low Noise Block (LNB): Positioned at the dish's focal point to receive signals.
Stepper or Servo Motors: Adjust the azimuth (horizontal) and elevation (vertical) angles of the antenna.
Microcontroller (e.g., Arduino, Raspberry Pi): Processes sensor data and controls the motors.
Potentiometers: Provide feedback on the antenna's current angle positions.
Fault Detection Sensors: Monitor for potential faults such as cable discontinuities or LNB failures.
Control Software: Runs on the microcontroller, handling real-time processing and decision-making.
Real-Time Angle Position Feedback
Real-time feedback on the antenna's angle position is essential for maintaining precise alignment. This feedback is typically provided by potentiometers or rotary encoders, which continuously monitor the azimuth and elevation angles. The microcontroller reads this data and adjusts the motors accordingly to keep the antenna aligned with the signal source.
Fault Tracking in Antenna Alignment Systems
Fault tracking is vital for the reliability and performance of the antenna system. Common faults include cable discontinuities, LNB malfunctions, and motor failures. Sensors integrated into the system can detect these faults and either notify the user or initiate corrective actions automatically.
Design and Implementation
1. Parabolic Dish and Feedhorn
The parabolic dish is designed to reflect incoming signals to a focal point where the feedhorn and LNB are located. The dish's size and shape depend on the specific application and frequency range.
2. Motors and Position Control
Stepper motors or servo motors are used to control the azimuth and elevation of
LinkedIn for Your Job Search June 17, 2024Bruce Bennett
This webinar helps you understand and navigate your way through LinkedIn. Topics covered include learning the many elements of your profile, populating your work experience history, and understanding why a profile is more than just a resume. You will be able to identify the different features available on LinkedIn and where to focus your attention. We will teach how to create a job search agent on LinkedIn and explore job applications on LinkedIn.
We recently hosted the much-anticipated Community Skill Builders Workshop during our June online meeting. This event was a culmination of six months of listening to your feedback and crafting solutions to better support your PMI journey. Here’s a look back at what happened and the exciting developments that emerged from our collaborative efforts.
A Gathering of Minds
We were thrilled to see a diverse group of attendees, including local certified PMI trainers and both new and experienced members eager to contribute their perspectives. The workshop was structured into three dynamic discussion sessions, each led by our dedicated membership advocates.
Key Takeaways and Future Directions
The insights and feedback gathered from these discussions were invaluable. Here are some of the key takeaways and the steps we are taking to address them:
• Enhanced Resource Accessibility: We are working on a new, user-friendly resource page that will make it easier for members to access training materials and real-world application guides.
• Structured Mentorship Program: Plans are underway to launch a mentorship program that will connect members with experienced professionals for guidance and support.
• Increased Networking Opportunities: Expect to see more frequent and varied networking events, both virtual and in-person, to help you build connections and foster a sense of community.
Moving Forward
We are committed to turning your feedback into actionable solutions that enhance your PMI journey. This workshop was just the beginning. By actively participating and sharing your experiences, you have helped shape the future of our Chapter’s offerings.
Thank you to everyone who attended and contributed to the success of the Community Skill Builders Workshop. Your engagement and enthusiasm are what make our Chapter strong and vibrant. Stay tuned for updates on the new initiatives and opportunities to get involved. Together, we are building a community that supports and empowers each other on our PMI journeys.
Stay connected, stay engaged, and let’s continue to grow together!
About PMI Silver Spring Chapter
We are a branch of the Project Management Institute. We offer a platform for project management professionals in Silver Spring, MD, and the DC/Baltimore metro area. Monthly meetings facilitate networking, knowledge sharing, and professional development. For more, visit pmissc.org.
LinkedIn Strategic Guidelines for June 2024Bruce Bennett
LinkedIn is a powerful tool for networking, researching, and marketing yourself to clients and employers. This session teaches strategic practices for building your LinkedIn internet presence and marketing yourself. The use of # and @ symbols is covered as well as going mobile with the LinkedIn app.
Delta International is an ISO Certified top recruiting agency in Pakistan, recognized for its highly experienced recruiters. With a diverse range of international jobs for Pakistani workers, Delta International maintains extensive connections with overseas employers, making it one of the top 10 recruitment agencies in Pakistan. It stands out in the list of recruitment agencies in Pakistan for its exceptional services.
https://www.ditrc.com/
Known for its expertise in the Gulf region, Delta International is among the top 10 international recruitment agencies, specializing in expert headhunting and candidate sourcing. This prominence places it in the list of top 10 overseas recruitment agencies in Pakistan. As one of the best overseas recruitment agencies in Pakistan, Delta International is a trusted name for manpower recruitment, particularly from Pakistan.
The agency is not just a leading name in Karachi but also recognized as one of the best recruitment agencies in Islamabad. Delta International consistently ranks as the top recruitment agency in Pakistan, earning its reputation among the top recruiting agencies in Pakistan. It is also regarded as one of the top overseas employment agencies in Pakistan.
For those seeking foreign jobs, Delta International is listed among the top overseas employment companies in Pakistan. Their extensive network and expertise make them a go-to for anyone looking at the list of overseas employment agencies in Pakistan. As a leading foreign jobs recruitment agency in Pakistan, they offer opportunities across various sectors.
Delta International is consistently listed among the top recruitment companies in Pakistan, known for providing the best recruitment services. It’s considered one of the best recruitment agencies in Pakistan and a prominent recruitment agency in Pakistan. The company excels in international recruitment, making it a key player among international recruitment agencies in Pakistan.
Their inclusion in the list of international recruitment agencies further attests to their excellence. As a top manpower agency in Pakistan, Delta International specializes in recruiting skilled professionals and labor for various industries, including construction, healthcare, IT, engineering, and hospitality.
Delta International is a leader among recruitment agencies in Pakistan, with a particular focus on overseas employment. They are one of the foremost overseas employment agencies in Pakistan, catering to technical jobs and other employment opportunities. Their role as overseas employment promoters highlights their commitment to connecting Pakistani talent with global opportunities.
In summary, Delta International is not only one of the best recruitment agencies in Pakistan but also a distinguished name among overseas employment agencies. Their extensive network and experienced recruiters make them a top choice for anyone seeking employment both locally and internationally.
5 key differences between Hard skill and Soft skillsRuchiRathor2
𝐓𝐡𝐞 𝐏𝐞𝐫𝐟𝐞𝐜𝐭 𝐁𝐥𝐞𝐧𝐝:
𝐖𝐡𝐲 𝐘𝐨𝐮 𝐍𝐞𝐞𝐝 𝐁𝐨𝐭𝐡 𝐇𝐚𝐫𝐝 & 𝐒𝐨𝐟𝐭 𝐒𝐤𝐢𝐥𝐥𝐬 𝐭𝐨 𝐓𝐡𝐫𝐢𝐯𝐞 💯
In today's dynamic and competitive market, a well-rounded skillset is no longer a luxury - it's a necessity.
While technical expertise (hard skills) is crucial for getting your foot in the door, it's the combination of hard and soft skills that propels you towards long-term success and career advancement. ✨
Think of it like this: Imagine a highly skilled carpenter with a masterful understanding of woodworking (hard skills). But if they struggle to communicate effectively with clients, collaborate with builders, or adapt to project changes (soft skills), their true potential remains untapped. 😐
The synergy between hard and soft skills is what creates true value in the workplace. Strong communication allows you to clearly articulate your technical expertise, while problem-solving skills help you navigate complex challenges alongside your team. 💫
By actively developing both sets of skills, you position yourself as a well-rounded professional who can not only perform tasks efficiently but also contribute meaningfully to a collaborative and dynamic work environment.
Go through the carousel and let me know your views 🤩
1. Lecture 2:
Java Semantics,
Validation
CS201j: Engineering Software?
University of Virginia David Evans
Computer Science http://www.cs.virginia.edu/~evans
2. Menu
• Objects in Java: Heap and Stack
• Validation: Testing and Analysis
2 September 2003 CS 201J Fall 2003 2
4. The Stack and Heap
String s = new String
s (“hello”);
java.lang.String
String is a type in the Java
“hello” API for representing
sequences of characters
Objects live on the Heap
new creates an Object on the Heap
Local variables live on the Stack
Point to objects on the Heap
2 September 2003 CS 201J Fall 2003 4
5. String s = new String
(“hello”);
String t = s;
s
java.lang.String
t
“hello”
2 September 2003 CS 201J Fall 2003 5
6. String s = new String
(“hello”);
String t = s;
s
java.lang.String java.lang.String
t
“hello”
“goodbye”
s = new String
(“goodbye”);
2 September 2003 CS 201J Fall 2003 6
7. Primitive Types
• Not everything in Java is an Object
• Some types are primitive types
– boolean, byte, char, double, float, int, long,
short
• Values of primitive types are stored
directly on the stack
2 September 2003 CS 201J Fall 2003 7
8. String s = new String
(“hello”);
String t = s;
s
int i = 201;
java.lang.String int j = i;
t
“hello”
i 201
j 201
How can we see the difference between
primitive types and objects?
2 September 2003 CS 201J Fall 2003 8
9. Equality
x == y
Object Types: same objects
Primitive Types: same value
x.equals (y)
Object Types: method that compares
values of objects
Primitive Types: doesn’t exist
2 September 2003 CS 201J Fall 2003 9
10. Mutability
• If an object is mutated, all references to
the object see the new value
StringBuffer sb = new (“hi”);
StringBuffer tb = sb;
tb.append (“gh”);
sb
java.lang.StringBuffer
tb
“high”
“hi”
2 September 2003 CS 201J Fall 2003 10
11. Immutable/Mutable Types
• Types can be mutable or immutable
– Objects of an immutable type never change
value after they are created
• String is immutable, StringBuffer is
mutable
– String.concat creates a new String object
– StringBuffer.append mutates the old object
2 September 2003 CS 201J Fall 2003 11
12. Java Semantics Question
public class Strings {
public static void test (String [] args) {
String s = new String ("hello");
String t = new String ("hello");
StringBuffer sb = new StringBuffer ("he");
StringBuffer tb = sb;
String s1 = "hello";
String t1 = "hello";
sb.append (“llo");
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!");
// What are the values of s, t, sb and tb now?
// Which of these are true:
// a) s == t b) s1 == t1 c) s == s1 d) s.equals (t) e) sb == tb f) t.equals (tb)
}
}
2 September 2003 CS 201J Fall 2003 12
13. Java Semantics Question
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “he”
String spec is not enough to s1 java.lang.String
determine if s, t, s1 and t1 are
the same objects! This is what t1 “hello”
Sun’s JDK 1.4 does. Other
implementations could correctly
do different things. Note (added Feb 2005): Nora Sovarel noticed that
this isn’t actually true. The JLS section on String
2 September 2003 CS 201J Fall specifies the behavior as shown.
literals 2003 13
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101083
14. Java Semantics Question
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “hello”
“he”
s1 java.lang.String
t1 “hello”
2 September 2003 CS 201J Fall 2003 14
15. Java Semantics Question
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “hello
“he”
goodbye!”
s1 java.lang.String
t1 “hello”
2 September 2003 CS 201J Fall 2003 15
16. Java Semantics Question
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “hello
“he”
goodbye!”
s1 java.lang.String
java.lang.String
“hello goodbye!”
t1 “hello”
2 September 2003 CS 201J Fall 2003 16
17. java.lang.String
“hello goodbye!”
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “hello
“he”
goodbye!”
s1 java.lang.String
java.lang.String
“hello goodbye!”
t1 “hello”
2 September 2003 CS 201J Fall 2003 17
18. After test returns? java.lang.String
“hello goodbye!”
public class Strings {
public static void test () {
String s = new String ("hello"); java.lang.String
String t = new String ("hello");
StringBuffer sb = new StringBuffer “hello”
("he"); s
StringBuffer tb = sb; java.lang.String
String s1 = "hello";
String t1 = "hello";
t
“hello”
sb.append (“llo"); sb java.lang.StringBuffer
tb.append (" goodbye!");
s.concat (" goodbye!");
t = s.concat (" goodbye!"); } } tb “hello
“he”
goodbye!”
s1 java.lang.String
java.lang.String
“hello goodbye!”
t1 “hello”
2 September 2003 CS 201J Fall 2003 18
20. Dictionary Definition
val·i·date
1. To declare or make legally valid.
2. To mark with an indication of official
sanction.
3. To establish the soundness of;
corroborate.
Can we do any of these with software?
2 September 2003 CS 201J Fall 2003 20
21. Java’s License
READ THE TERMS OF THIS AGREEMENT AND ANY
PROVIDED SUPPLEMENTAL LICENSE TERMS
(COLLECTIVELY "AGREEMENT") CAREFULLY BEFORE
OPENING THE SOFTWARE MEDIA PACKAGE. BY
OPENING THE SOFTWARE MEDIA PACKAGE, YOU
AGREE TO THE TERMS OF THIS AGREEMENT. IF YOU
ARE ACCESSING THE SOFTWARE ELECTRONICALLY,
INDICATE YOUR ACCEPTANCE OF THESE TERMS BY
SELECTING THE "ACCEPT" BUTTON AT THE END OF
THIS AGREEMENT. IF YOU DO NOT AGREE TO ALL
THESE TERMS, PROMPTLY RETURN THE UNUSED
SOFTWARE TO YOUR PLACE OF PURCHASE FOR A
REFUND OR, IF THE SOFTWARE IS ACCESSED
ELECTRONICALLY, SELECT THE "DECLINE" BUTTON AT
2 September 2003 THIS CS 201J Fall 2003
THE END OF AGREEMENT. 21
22. Java’s License
5. LIMITATION OF LIABILITY. TO THE EXTENT
NOT PROHIBITED BY LAW, IN NO EVENT WILL
SUN OR ITS LICENSORS BE LIABLE FOR ANY
LOST REVENUE, PROFIT OR DATA, OR FOR
SPECIAL, INDIRECT, CONSEQUENTIAL,
INCIDENTAL OR PUNITIVE DAMAGES,
HOWEVER CAUSED REGARDLESS OF THE
THEORY OF LIABILITY, ARISING OUT OF OR
RELATED TO THE USE OF OR INABILITY TO USE
SOFTWARE, EVEN IF SUN HAS BEEN ADVISED
OF THE POSSIBILITY OF SUCH DAMAGES. …
2 September 2003 CS 201J Fall 2003 22
23. Java’s License
2. RESTRICTIONS. … Unless enforcement is
prohibited by applicable law, you may not
modify, decompile, or reverse engineer
Software. You acknowledge that Software is
not designed, licensed or intended for use in
the design, construction, operation or
maintenance of any nuclear facility. Sun
disclaims any express or implied warranty of
fitness for such uses.
2 September 2003 CS 201J Fall 2003 23
24. Software Validation
• Process designed to increase our
confidence that a program works as
intended
• For complex programs, cannot often make
guarantees
• This is why typical software licenses don’t
make any claims about their program
working
2 September 2003 CS 201J Fall 2003 24
25. Increasing Confidence
• Testing
– Run the program on set of inputs and check
the results
• Verification
– Argue formally or informally that the program
always works as intended
• Analysis
– Poor programmer’s verification: examine the
source code to increase confidence that it
works as intended
2 September 2003 CS 201J Fall 2003 25
26. Testing
• If all the test cases produce the correct
results, you know that a particular
execution of the program on each of the
test cases produced the correct result
• Concluding that this means the program is
correct is like concluding there are no fish
in the river because you didn’t catch one!
2 September 2003 CS 201J Fall 2003 26
27. Exhaustive Testing
• Test all possible inputs
• PS1: 50x50 grid, all cells can be either
dead or alive before starting
22500 =
3758280234548012036833624189723865048677365517592586770565238397822316814983377085357327257526588
4433370245774952605776030922789135161776565190731096878023646469404331623656214672441647859113183
2593729111221580180531749232777515579969899075142213969117994877343802049421624954402214529390781
6475633395350247725849016076668629825679186228496361602088773658349501637901885230262474405073903
8203218889238610990586970675314324392119848221207544402243336655478685655938968958563812658237722
4037721702239991441466026185752651502936472280911018500320375496336749951569521541850441747925844
0662952796718726052857925526601307020479982183347493563216774695296825517658582675027158940078877
27250070780350262952377214028842297486263597879792176338220932619489509376
But that’s not all: all possible start stop step interactions,
different platforms, how long to you need to run it, etc.
2 September 2003 CS 201J Fall 2003 27
28. Selective Testing
• We can’t test everything, pick test cases
with high probability of finding flaws
• Black-Box Testing: design tests looking
only at specification
• Glass-Box Testing: design tests looking
at code
– Path-complete: at least one test to exercise
each path through code
2 September 2003 CS 201J Fall 2003 28
29. Black-Box Testing
public CellState getNextState ()
// MODIFIES: this
// EFFECTS: Returns the next state for this cell. If a cell is currently
// dead cell and has three live neighbors, then it becomes a live cell.
// If a cell is currently alive and has two or three live neighbors it
// remains alive. Otherwise, the cell dies.
Test all paths through the specification:
1. currently dead, three live neighbors
2. currently alive, two live neighbors
3. currently alive, three live neighbors
4. currently dead, < 3 live neighbors
5. currently dead, > 3 live neighbors
6. currently alive, < 2 live neighbors
7. currently alive, >201J Fallneighbors
2 September 2003 CS
3 live 2003 29
30. Black-Box Testing
public CellState getNextState ()
// MODIFIES: this
// EFFECTS: Returns the next state for this cell. If a cell is currently
// dead cell and has three live neighbors, then it becomes a live cell.
// If a cell is currently alive and has two or three live neighbors it
// remains alive. Otherwise, the cell dies.
Test all paths through the specification (7 tests)
Test boundary conditions
1. all neighbors are dead
2. all neighbors are alive
3. cell is at a corner of the grid
4. cell is at an edge of the grid
2 September 2003 CS 201J Fall 2003 30
31. Glass-Box Testing
public CellState getNextState ()
// MODIFIES: this
// EFFECTS: Returns the next state for this cell. If a cell is currently
// dead cell and has three live neighbors, then it becomes a live cell.
// If a cell is currently alive and has two or three live neighbors it
// remains alive. Otherwise, the cell dies.
{
if (countAliveNeighbors () == 3) {
return CellState.createAlive ();
} else if (getState ().isAlive () && countAliveNeighbors () == 2) {
return CellState.createAlive ();
} else {
return CellState.createDead ();
}
}
Test all paths through the code (4)
2 September 2003 CS 201J Fall 2003 31
32. Path-Complete Testing
• Insufficient
– Often, bugs are missing paths
• Impossible
– Most programs have essentially infinite
number of paths
– Loops and recursion
• Test with zero, one and several iterations
2 September 2003 CS 201J Fall 2003 32
33. Testing Recap
• Testing can find problems, not to prove
your program works
– Since exhaustive testing is impossible, select
test cases with maximum probability of finding
bugs
– A successful test case is one that reveals a
bug in your program!
• Typically at least 40% of cost of software
project is testing, often ~80% of cost for
safety-critical software
2 September 2003 CS 201J Fall 2003 33
34. Charge
• Increase confidence a program works by:
– Testing: sample possible executions, trying to
find ones that don’t work
– Analysis: check properties about all possible
executions by examining code
• PS2: a lot longer and harder than PS1
2 September 2003 CS 201J Fall 2003 34