[Solved] Assignment4_1,2 ,3

$25

File Name: Assignment4_1,2_,3.zip
File Size: 169.56 KB

SKU: [Solved] Assignment4_1,2 ,3 Category: Tag:
5/5 - (1 vote)

5/5 – (3 votes)

Assignment4_1.java as the file name and Assignment4_1 as the class name

Write a console program with a static method printHello() (in addition to main() method which is also static) that prints out Hello World. Call that method from main().

Assignment4_2.java as the file name and Assignment4_2 as the class name Write a console program with static method inc() that takes value of type int and returns that value increased by one. In main() method do the following: Ask a user to enter an integer value Call method inc() and pass user input (integer value) into that method Print returned result

Assignment4_3.java as the file name and Assignment4_3 as the class name

Write a console program with static method inc() that takes value of type int and returns that value increased by one. In main() public static void localModification(int a) { a++; } Call that method from main() while passing some integer value stored in a variable, for instance: public static void main(String[] args) { int A = 5; localModification(A); System.out.println(A); } Make sure that value of A, printed in main(), is not affected by local modification made within the localModification() method, i.e. value 5 is printed. Try to understand why.

Task: Change declaration and/or implementation and/or call of the localModification() method, such that print statement in main() method prints incremented value, i.e. 6.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Assignment4_1,2 ,3
$25