Exam Objective 4.2 Given an algorithm as pseudo-code, determine the correct scope for a variable used in the algorithm and develop code to declare variables in any of the following scopes: instance variable, method parameter, and local variable.
Chapter 4:Object-Oriented Basic ConceptsIt Academy
Exam Objective 1.1 Describe, compare, and contrast primitives (integer, floating point,boolean, and character), enumeration types, and objects.
Exam Objective 3.1 Develop code that uses primitives, enumeration types, and object references, and recognize literals of these types.
Chapter 4:Object-Oriented Basic ConceptsIt Academy
Exam Objective 1.1 Describe, compare, and contrast primitives (integer, floating point,boolean, and character), enumeration types, and objects.
Exam Objective 3.1 Develop code that uses primitives, enumeration types, and object references, and recognize literals of these types.
Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.
Generics are a facility of generic programming that were added to the Java programming language in 2004 within version J2SE 5.0. They were designed to extend Java's type system to allow “a type or method to operate on objects of various types while providing compile-time type safety”
The Java collections framework supports generics to specify the type of objects stored in a collection instance.
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
Learn about how to define and invoke methods in Java, how to use parameters and return results. Watch the video lesson here:
https://softuni.org/code-lessons/java-foundations-certification-methods
Porque baixa dosagem é mais eficiente do que alta dosagem quando se trata de ferro
Restaurar contagens de ferro demanda tempo, assim como o aparecimento e o desenvolvimento de deficiência de ferro não acontece da noite para o dia. É uma questão de equilíbrio, onde a absorção de ferro deve corresponder às perdas.
Generic programming is a style of computer programming in which algorithms are written in terms of types to-be-specified-later that are then instantiated when needed for specific types provided as parameters.
Generics are a facility of generic programming that were added to the Java programming language in 2004 within version J2SE 5.0. They were designed to extend Java's type system to allow “a type or method to operate on objects of various types while providing compile-time type safety”
The Java collections framework supports generics to specify the type of objects stored in a collection instance.
Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible.
Learn about how to define and invoke methods in Java, how to use parameters and return results. Watch the video lesson here:
https://softuni.org/code-lessons/java-foundations-certification-methods
Porque baixa dosagem é mais eficiente do que alta dosagem quando se trata de ferro
Restaurar contagens de ferro demanda tempo, assim como o aparecimento e o desenvolvimento de deficiência de ferro não acontece da noite para o dia. É uma questão de equilíbrio, onde a absorção de ferro deve corresponder às perdas.
Type Conversion, Precedence and AssociativityAakash Singh
This presentation is about Type Conversion, Precedence and Associativity which are important concepts for problem solving in programming languages like C, C++, Java, etc. It will surely help you to improve your knowledge.
Automatic Variables
extern variables
static variables
register variables
Examples of above listed variables.
Summary of storage place, Initial value, scope and life of variables.
Static variable is explained using simple terms and example followed by conclusion. An application is demonstrated using simple example. The examples provided in slide can be taken as a reference by c,c++,java,php students.
CIS 1403 lab 3 functions and methods in JavaHamad Odhabi
This lab discusses and provides examples of both built-in and user-defined functions. In Java function are referred to as methods. Therefore, in the rest of this lab, the term methods will be used to refer to functions. The lab will cover the type of methods, naming of functions, the scope of variables and recursion.
Classes, Objects and Method - Object Oriented Programming with JavaRadhika Talaviya
Class is template for an object and object is instance of a class.
When we create a class, we are creating a new data type. we can use this type to declare objects of that type.
Chapter 12:Understanding Server-Side TechnologiesIt Academy
Exam Objective 8.4 Describe at a high level the fundamental benefits and drawbacks of using J2EE server-side technologies, and describe and compare the basic characteristics of the web-tier, business-tier, and EIS tier.
Chapter 10:Understanding Java Related Platforms and Integration TechnologiesIt Academy
Exam Objective 6.1 Distinguish the basic characteristics of the three Java platforms: J2SE, J2ME, and J2EE, and given a high-level architectural goal, select the appropriate Java platform or platforms.
Chapter 11:Understanding Client-Side TechnologiesIt Academy
Exam Objective 7.1 Describe at a high level the basic characteristics, benefits, and drawbacks of creating thin-clients using HTML and JavaScript and the related deployment issues and solutions.
Chapter 9:Representing Object-Oriented Concepts with UMLIt Academy
The SCJA exam requires minimum knowledge of the UML Infrastructure and Superstructure specifications. Of the 14 UML diagram types, the class diagram is the only diagram type on the exam.
There is value in understanding UML diagrams and features that are outside the scope of this exam.
So in your independent research on UML, don’t ignore the other diagram types since this knowledge will surely come in handy later for you at work.
Chapter 6:Working with Classes and Their RelationshipsIt Academy
Exam Objective 1.3 Describe, compare, and contrast class compositions, and associations (including multiplicity: one-to-one, one-to-many, and many-to-many), and association navigation.
Chapter 3:Programming with Java Operators and StringsIt Academy
Exam Objective 4.5 Given an algorithm as pseudo-code, develop code that correctly applies the appropriate operators, including assignment operators (limited to: =, +=, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --), relational operators (limited to: <,><=,>, >=, ==, !=), logical operators (limited to: !, &&, ||), to produce a desired result. Also, write code that determines the equality of two objects or two primitives.
Chapter 3 : Programming with Java Operators and StringsIt Academy
Exam Objective 4.5 Given an algorithm as pseudo-code, develop code that correctly applies the appropriate operators, including assignment operators (limited to: =, +=, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --), relational operators (limited to: <,><=,>, >=, ==, !=), logical operators (limited to: !, &&, ||), to produce a desired result. Also, write code that determines the equality of two objects or two primitives.
Chapter 2 : Programming with Java StatementsIt Academy
Exam Objective 4.1 Describe, compare, and contrast these three fundamental types of statements: assignment, conditional, and iteration, and given a description of an algorithm, select the appropriate type of statement to design the algorithm
JAVA CERTIFICATION EXAM OBJECTIVES
COVERED IN THIS CHAPTER:
3.2 Given a scenario involving navigating file systems, reading
from files, or writing to files, develop the correct solution
using the following classes (sometimes in combination) from
java.io: BufferedReader,BufferedWriter, File, FileReader,
FileWriter and PrintWriter.
3.3 Develop code that serializes and/or de-serializes objects
using the following APIs from java.io: DataInputStream,
DataOutputStream, FileInputStream, FileOutputStream,
ObjectInputStream, ObjectOutputStream, and Serializable.
In addition, develop Serializable classes that correctly
declare and use transient variables and private readObject
and writeObject methods. Given a scenario and/or code
example, recognize when, if, and which constructors will be
called in an object's inheritance chain during deserialization.
chap 8 : The java.lang and java.util Packages (scjp/ocjp)It Academy
JAVA CERTIFICATION EXAM OBJECTIVES
COVERED IN THIS CHAPTER:
3.1 Develop code that uses the primitive wrapper classes
(such as Boolean, Character, Double, Integer, etc.) and/or
autoboxing and unboxing. Discuss the differences between
the String, StringBuilder, and StringBuffer classes.
3.4 Use standard J2SE APIs in the java.text package to
correctly format or parse dates, numbers, and currency
values for a specific locale, and, given a scenario, determine
the appropriate methods to use if you want to use the default
locale or a specific locale. Describe the purpose and use of the
java.util.Locale class.
3.5 Write code that uses standard J2SE APIs in the java.util
and java.util.regex packages to format or parse strings or
streams. For strings, write code that uses the Pattern and
Matcher classes and the String.split method. Recognize
and use regular expression patterns for matching (limited
to . (dot), * (star), + (plus), ?, \d, \s, \w, [], ()). The use of
*, +, and ? will be limited to greedy quantifiers, and the
parenthesis operator will be used only as a grouping
mechanism, not for capturing content during matching.
For streams, write code using the Formatter and Scanner
classes and the PrintWriter.format/printf methods. Recognize
and use formatting parameters (limited to %b, %c, %d, %f, %s)
in format strings.
6.1 Given a design scenario, determine which collection
classes and/or interfaces should be used to properly
implement that design, including the use of the
Comparable interface.
JAVA CERTIFICATION EXAM OBJECTIVES
COVERED IN THIS CHAPTER:
4.1 Write code to define, instantiate, and start new threads
using both java.lang.Thread and java.lang.Runnable.
4.2 Recognize the states in which a thread can exist, and
identify ways in which a thread can transition from one state
to another.
4.3 Given a scenario, write code that makes appropriate use
of object locking to protect static or instance variables from
concurrent access problems.
4.4 Given a scenario, write code that makes appropriate use of wait, notify, or notifyAll.
chap 6 : Objects and classes (scjp/ocjp)It Academy
.1 Develop code that declares classes (including abstract
and all forms of nested classes), interfaces, and enums,
and includes the appropriate use of package and import
statements (including static imports).
1.4 Develop code that declares both static and non-static
methods, and - if appropriate - use method names that
adhere to the JavaBeans naming standards. Also develop
code that declares and uses a variable-length argument list.
1.5 Given a code example, determine if a method is correctly
overriding or overloading another method, and identify
legal return values (including covariant returns), for the
method.
1.6 Given a set of classes and superclasses, develop
constructors for one or more of the classes. Given a
class declaration, determine if a default constructor will
be created, and if so, determine the behavior of that
constructor. Given a nested or non-nested class listing,
write code to instantiate the class.
5.1 Develop code that implements tight encapsulation,
loose coupling, and high cohesion in classes, and describe
the benefits.
5.2 Given a scenario, develop code that demonstrates the
use of polymorphism. Further, determine when casting will
be necessary and recognize compiler vs. runtime errors
related to object reference casting.
5.3 Explain the effect of modifiers on inheritance with
respect to constructors, instance or static variables, and
instance or static methods.
chap4 ; Flow Control, Assertions, and Exception Handling (scjp/ocjp)It Academy
2.1 Develop code that implements an if or switch statement;
and identify legal argument types for these statements.
2.2 Develop code that implements all forms of loops and
iterators, including the use of for, the enhanced for loop
(for-each), do, while, labels, break, and continue; and explain
the values taken by loop counter variables during and after
loop execution.
2.3 Develop code that makes use of assertions, and distinguish
appropriate from inappropriate uses of assertions.
2.4 Develop code that makes use of exceptions and exception
handling clauses (try, catch, finally), and declares methods and
overriding methods that throw exceptions.
2.5 Recognize the effect of an exception arising at a specified
point in a code fragment. Note that the exception may be a
runtime exception, a checked exception, or an error.
2.6 Recognize situations that will result in any of the following
being thrown: ArrayIndexOutOfBoundsException, ClassCast-
Exception, IllegalArgumentException, IllegalState-Exception,
NullPointerException, NumberFormatException, Assertion-
Error, ExceptionInInitializerError, StackOverflow-Error or
NoClassDefFoundError.ÊUnderstand which of these are
thrown by the virtual machine and recognize situations in
which others should be thrown programatically.
chap4 : Converting and Casting (scjp/ocjp)It Academy
5.2 Given a scenario, develop code that demonstrates the
use of polymorphism. Further, determine when casting will
be necessary and recognize compiler vs. runtime errors
related to object reference casting.
7.6 Write code that correctly applies the appropriate
operators including assignment operators (limited to: =,
+ =, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --),
relational operators (limited to: <,>< =, >, > =, = =, !=), the
instanceof operator, logical operators (limited to: &, |, ^, !,
&&, ||), and the conditional operator ( ? : ), to produce a
desired result. Write code that determines the equality of
two objects or two primitives.
1.2 Develop code that declares an interface. Develop code
that implements or extends one or more interfaces. Develop
code that extends an abstract class.
1.4 Develop code that declares both static and non-static
methods, and - if appropriate - use method names that
adhere to the JavaBeans naming standards. Also develop
code that declares and uses a variable-length argument list.
5.3 Explain the effect of modifiers on inheritance with
respect to constructors, instance or static variables, and
instance or static methods.
7.1 Given a code example and a scenario, write code
that uses the appropriate access modifiers, package
declarations, and import statements to interact with
(through access or inheritance) the code in the example.
chap 2 : Operators and Assignments (scjp/ocjp)It Academy
Write code that correctly applies the appropriate
operators including assignment operators (limited to: =,
+ =, -=), arithmetic operators (limited to: +, -, *, /, %, ++, --),
relational operators (limited to: <,>< =, >, > =, = =, !=), the
instanceof operator, logical operators (limited to: &, |, ^, !,
&&, ||), and the conditional operator ( ? : ), to produce a
desired result. Write code that determines the equality of
two objects or two primitives.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
2. Understanding Variable Scope
• Exam Objective 4.2 Given an algorithm as pseudo-code,
determine the correct scope for a variable used in the algorithm
and develop code to declare variables in any of the following
scopes: instance variable, method parameter, and local variable.
2
3. Variables and Initialization
Member variable A member variable of a class is created when an
instance is created, and it is destroyed when the object is destroyed.
Subject to accessibility rules and the need for a reference to the object,
member variables are accessible as long as the enclosing object exists.
Automatic variable An automatic variable of a method is created on entry
to the method and exists only during execution of the method, and
therefore it is accessible only during the execution of that method. (You’ll see
an exception to this rule when you look at inner classes, but don’t worry
about that for now.)
Class variable A class variable (also known as a static variable) is created
when the class is loaded and is destroyed when the class is unloaded.
There is only one copy of a class variable, and it exists regardless of the
number of instances of the class, even if the class is never instantiated.
Static variables are initialized at class load time
Ben Abdallah Helmi Architect en
3
J2EE
4. All member variables that are not explicitly assigned a value upon declaration are
automatically assigned an initial value. The initialization value for member
variables depends on the member variable’s type.
A member value may be initialized in its own declaration line:
1. class HasVariables {
2. int x = 20;
3. static int y = 30;
When this technique is used, nonstatic instance variables are initialized just before
the class constructor is executed; here x would be set to 20 just before invocation
of any HasVariables constructor.
Static variables are initialized at class load time; here y would be set to 30 when the
HasVariables class is loaded.
Ben Abdallah Helmi Architect en
4
J2EE
5. Automatic variables (also known as method local variables are not initialized by the system; every automatic variable must be explicitly
initialized before being used. For example, this method will not compile:
1. public int wrong() {
2. int i;
3. return i+5;
4. }
The compiler error at line 3 is, “Variable i may not have been initialized.” This error often appears when initialization of an automatic variable
occurs at a lower level of curly braces than the use of that variable. For example, the following method returns the fourth root of a
positive number:
1. public double fourthRoot(double d) { 2. double result;
3. if (d >= 0) {
4. result = Math.sqrt(Math.sqrt(d));
5. } 6. return result; 7. }
Here the result is initialized on line 4, but the initialization takes place within the curly braces of lines 3 and 5. The compiler will flag line 6,
complaining that “Variable result may not have been initialized.” A common solution is to initialize result to some reasonable default as
soon as it is declared:
1. public double fourthRoot(double d) {
2. double result = 0.0; // Initialize
3. if (d >= 0) {
4. result = Math.sqrt(Math.sqrt(d));
5. } 6. return result; 7. }
Ben Abdallah Helmi Architect en
5
J2EE
6. 5. Consider the following line of code:
int[] x = new int[25];
After execution, which statements are true? (Choose all that
apply.)
A. x[24] is 0
B. x[24] is undefined
C. x[25] is 0
D. x[0] is null
E. x.length is 25
Ben Abdallah Helmi Architect en
6
J2EE
7. 5. A, E. The array has 25 elements, indexed from 0
through 24. All elements are initialized to 0.
Ben Abdallah Helmi Architect en
7
J2EE
8. Argument Passing: By Reference or by
Value
1. public void bumper(int bumpMe) {
2. bumpMe += 15;
3. }
Line 2 modifies a copy of the parameter passed by the
caller. For example
1. int xx = 12345;
2. bumper(xx);
3. System.out.println(“Now xx is “ + xx);
line 3 will report that xx is still 12345.
Ben Abdallah Helmi Architect en
8
J2EE
9. When Java code appears to store objects in variables or pass
objects into method calls, the object references are stored or
passed.
1. Button btn;
2. btn = new Button(“Pink“);
3. replacer(btn);
4. System.out.println(btn.getLabel());
5.
6. public void replacer(Button replaceMe) {
7. replaceMe = new Button(“Blue“);
8. }
Line 2 constructs a button and stores a reference to that button in
btn. In line 3, a copy of the reference is passed into the replacer()
method.
the string printed out is “Pink”.
Ben Abdallah Helmi Architect en
9
J2EE
10. 1. Button btn;
2. btn = new Button(“Pink“);
3. changer(btn);
4. System.out.println(btn.getLabel());
5.
6. public void changer(Button changeMe) {
7. changeMe.setLabel(“Blue“);
8. }
the value printed out by line 4 is “Blue”.
Ben Abdallah Helmi Architect en
10
J2EE
11. Arrays are objects, meaning that programs deal with
references to arrays, not with arrays themselves. What
gets passed into a method is a copy of a reference to an
array. It is therefore possible for a called method to
modify the contents of a caller’s array.
Ben Abdallah Helmi Architect en
11
J2EE
12. 6.Consider the following application:
class Q6 {
public static void main(String args[]) {
Holder h = new Holder();
h.held = 100;
h.bump(h);
System.out.println(h.held);
}
}
class Holder {
public int held;
public void bump(Holder theHolder) {
theHolder.held++; }
}
}
What value is printed out at line 6?
A. 0
B. 1
C. 100
D. 101
Ben Abdallah Helmi Architect en
12
J2EE
13. 6. D. A holder is constructed on line 3. A reference to
that holder is passed into method bump() on line 5.
Within the method call, the holder’s held variable is
bumped from 100 to 101.
Ben Abdallah Helmi Architect en
13
J2EE
14. 7. Consider the following application:
1. class Q7 {
2. public static void main(String args[]) {
3. double d = 12.3;
4. Decrementer dec = new Decrementer();
5. dec.decrement(d);
6. System.out.println(d);
7. }
8. }
9.
10. class Decrementer {
11. public void decrement(double decMe) {
12. decMe = decMe - 1.0;
13. }
14. }
Review Questions 31
What value is printed out at line 6?
A. 0.0
B. 1.0
C. 12.3
D. 11.3
Ben Abdallah Helmi Architect en
14
J2EE
15. 7. C. The decrement() method is passed a copy of the
argument d; the copy gets decremented, but the
original is untouched.
Ben Abdallah Helmi Architect en
15
J2EE
16. 20. Which of the following are true? (Choose all that
apply.)
A. Primitives are passed by reference.
B. Primitives are passed by value.
C. References are passed by reference.
D. References are passed by value.
Ben Abdallah Helmi Architect en
16
J2EE
17. 20. B, D. In Java, all arguments are passed by value.
Ben Abdallah Helmi Architect en
17
J2EE
19. Constructing Methods
• Exam Objective 4.4 Given an algorithm with multiple inputs
and an output, develop method code that implements the
algorithm using method parameters, a return type, and the
return statement, and recognize the effects when object
references and primitives are passed into methods that
modify them.
19
20. • The SCJA exam will likely have a question asking the
difference between passing variables by reference and
value. The question will not directly ask you the difference.
• It will present some code and ask for the output. In the group
of answers to select from, there will be an answer that will be
correct if you assume the arguments are passed by value,
and another answer that will be correct if the arguments
were passed by reference.
• It is easy to get this type of question incorrect if passing
variables by reference and value are poorly understood.
20
21. Declaring a Return Type
• A return statement must be the keyword return followed
by a variable or a literal of the declared return type. Once
the return statement is executed, the method is finished.
21
22. Two-Minute Drill
• A variable’s scope defines what parts of the code have
access to that variable.
• An instance variable is declared in the class, not inside of
any method. It is in scope for the entire method and remains
in memory for as long as the instance of the class it was
declared in remains in memory.
• Method parameters are declared in the method declaration;
they are in scope for the entire method.
• Local variables may be declared anywhere in code. They
remain in scope as long as the execution of code does not
leave the block they were declared in.
22
23. • Code that invokes a method may pass arguments to it for
input.
• Methods receive arguments as method parameters.
• Primitives are passed by value.
• Objects are passed by reference.
• Methods may return one variable or none at all. It can be
a primitive or an object.
• A method must declare the data type of any variable it
returns.
• If a method does not return any data, it must use void as
its return type.
23