forked from Agrasha-Janarthanan/MyJobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew 2.txt
52 lines (45 loc) · 3.24 KB
/
new 2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Write a program to,
+ program to store and retrieve four boolean flags using a single int
+ $ create a Employee class with properties: id and name, a constructor which initializes name, a mechanism to automatically assign id by incrementing the previous id. Create and print 10 employee objects using Object.toString()
+ list down the differences between the classname of arrays of all inbuilt types
+ print the type of the result value of following expressions
- 100 / 24
- 100.10 / 10
- 'Z' / 2
- 10.5 / 0.5
- 12.4 % 5.5
- 100 % 56
+ demonstrate what happens when mixing primitive with respective Wrapper types for the above operations, and the following:
+ $ demonstrate inheritance, overloading, overriding using Animal, Dog, Cat and Snake class of objects
+ $ demonstrate overloading with varargs
+ demonstrate overloading with Wrapper types
- print the classname of all the primitive data types (Note: not the wrapper types)
- demonstrate access specifiers
- write a class to throw your own exception if the input value is not valid
- To invert the value of a boolean, which operator would you use?
- The following code creates one array and one string object. How many references to those objects exist after the code executes? Is either object eligible for garbage collection?
...
String[] students = new String[10];
String studentName = "Peter Parker";
students[0] = studentName;
studentName = null;
...
- How does a program destroy an object that it creates?
- The program Problem.java doesn't compile. What do you need to do to make it compile? Why?
- Compile and run Class1.java. What is the output?
- The following exercises involve modifying the class DataStructure.java
- Define a method named print(DataStructureIterator iterator). Invoke this method with an instance of the class EvenIterator so that it performs the same function as the method printEven.
- Invoke the method print(DataStructureIterator iterator) so that it prints elements that have an odd index value. Use an anonymous class as the method's argument instead of an instance of the interface DataStructureIterator.
- Define a method named print(java.util.Function<Integer, Boolean> iterator) that performs the same function as print(DataStructureIterator iterator). Invoke this method with a lambda expression to print elements that have an even index value. Invoke this method again with a lambda expression to print elements that have an odd index value.
- Define two methods so that the following two statements print elements that have an even index value and elements that have an odd index value:
DataStructure ds = new DataStructure()
// ...
ds.print(DataStructure::isEvenIndex);
ds.print(DataStructure::isOddIndex);
- Write a class that implements the CharSequence interface found in the java.lang package. Your implementation should return the string backwards. Write a small main method to test your class; make sure to call all four methods.
- Download the source files as listed here.
Client
Server
Utilities
- Implement the changes you proposed in questions 1 through 3 using the source files you just downloaded.
- Compile the revised source files.