0% found this document useful (0 votes)
8 views95 pages

Jayaprakash

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views95 pages

Jayaprakash

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 95

ANS:

aCount=a;
setGcount(g);
ANS:
The code fails to compile at line n1.

ANS:
Ensure that the class definition
used is the same as the class
definition used bu Java runtime at
the time when the object was
serialized.

Implement secure serialization by


generating secure object hash or
using encryption.
ANS:
Map<String, List<Employee>> r1 =
roster.stream()
.collect (Collectors.groupingBy
(Employee::getNeighborhood,
Collectors.filtering (p,
Collectors.toList())));

Map<Optional<String>,
List<Employee>> r4 =
roster.stream()
.collect (Collectors.groupingBy(f,
Collectors.filtering(p,
Collectors.toList())));

ANS: (mismatch=1, am=2, first=1,


second=1)
ANS:
getTotalCount
getTcount
ANS:
Hello
ANS:
The program executes and prints
nothing.

ANS: The body of foo can throw


FooException or one of its
subclasses.
ANS:Replace Line 3 with public void
addProcess (T W) {
ANS: if(items.stream().anyMatch(i-
>.count<0)) {

ANS: To process the current item


and return a stream.
ANS: 10
ANS: implementa A //position 1
@override //position 2
ANS: It compiles without errors.
ANS: class A extends Throwable {
ANS: left and right must be private
ANS: Mr.Blue
ANS: gi hk il
ANS:
Continue a;
j--;
ANS: hey oh hi yo ey
ANS: if(p.test(numer)) {
ANS:
system.out.println(IntStream.range
Closed(1,100).count() );

ANS: Inserting “requires citizen;”,


at greeting’s module –
info.java.enables com.name
members to the greeting module.
ANS: Only the public classes in the
com.name package of the citizen
module are accessible at the
greeting module.
ANS: 1

ANS: The program compiles fine.

ANS: A
ConcurrentModificationException is
thrown at run time.
ANS:
F2.foo(li) prints Hello world!
F1.foo(li) prints Bonjour le monde!
B1.foo(li) prints Hola Mundo!
ANS:
B cannot be abstract
B is a subtype of A
A cannot be final
ANS:
Move Character
Move GameObject
Move GameObject
ANS: 15
ANS: Double b=Double.valueOf(i);
Double d=1;

ANS: 80
ANS:
It must be executed once and only
before the first call to
DriverManager to get a Connection
Using the named JDBC driver.

ANS: public static final String


ALPHA = “alpha”;
ANS: reader.read(characters);
ANS: Nothing

ANS:
Paths.get(URI.create(file:///
domains/oracle/test.txt))
Path.get(“foo”)
ANS:
System.out.println
(Season.SPRING);
System.out.println(Season.valueOf(
“SPRING”));
System.out.println(sA[1]);
ANS: 1 2 [1,2,3,four] 3 4
ANS: Make foo and setB
synchronized.
ANS:
@Resource (“Customer1”)
@Resource((“Customer1”,
“Customer2”))
ANS:
A class declaration
An interface declaration
ANS: 5
ANS: Changed to Java
ANS: Marry
Joe
ANS: module com.company,clients {
Exports
com.company.client;
}
ANS: Test.class -> java.base
Test.class-> java.sql
ANS: 4
ANS: false
True
False

ANS: locale = Locate.getDefault();


Locale= new Locale(“en”,
“GB”);
ANS: 2,5
4,5
4,5
ANS: Hello
ANS: Good Night, Potter
ANS: The author of the class wants
to discourage people from using
the class in any way.

Using the class will cause the Java


compiler to give a warning.
ANS: @interface Author {
String name() default “ “;
String date();
}
ANS: Nothing
ANS: abcd
ANS: The compilation fails.
ANS: test:null
ANS: B is a subtype of A
B cannot be abstract
A cannot be final
ANS: Hello world!
Hello world!
Bonjour le monde!
ANS: line n4
ANS: 234
ANS: Mr.Blue
ANS: The code does not compile
successfully
ANS: Future<String> future
es.submit(() -> "Pong");
ANS: Message from Copier:
Attempt00
ANS: Change Line 2 access modifier
to protected:
protected void checkValue (Object
value)
throws IllegalArgumentException;

Change Line 1 to an abstract class:


public abstract class API (
ANS: implements A // position 1
@Override // position 2
ANS: Map<String,
List<Employee>> e3 =
roster.stream()
.collect (Collectors.groupingBy(
e->
Optional.ofNullable(e.getNeighborh
ood()) .get()
));
ANS: Map<String,
List<Employee>> r1 roster.stream()
.collect (Collectors.groupingBy
(Employee::getNeighborhood,
Collectors.filtering (p,
Collectors.toList())));

Map<Optional<String>,
List<Employee>> r4 roster.stream()
.collect (Collectors.groupingBy (f,
Collectors.filtering (p,
Collectors.toList())));
ANS: It is subjected to livelock
ANS: An exception is thrown at
runtime.
ANS: The compilation fails.
ANS: Fragment 2 because it
prevents SQL injection.
ANS: 08

ANS: myList.stream()
.collect (Collectors.tocollection
(TreeSet::new)) .stream().forEach
(x-> System.out.print(x));
ANS: The compilation fails

ANS: Predicate<String> function =


s-> s.contains(“N”);
ANS: if (items.Stream().anymatch(i-
> i.count<0)) {
ANS: To process the curren item
and return a stream.

ANS: reader.read(characters);
ANS: A currenModificationException
is thrown at run time.
ANS: abc null

ANS: Create a method that


validates the hostName and
portNumber parameters before
opening the socket.
ANS: java.base
ANS: On execution of the given
commands, the program prints:
Module: unnamed module @<<hash
code>>
Name: null
Descriptor:null

ANS: Only the public classes in the


com.name package of the citizen
module are accessible at the
greeting module.
ANS: java.desktop

ANS: Add catch (L e)


ANS: Unary Operator<integer> uo=
(var x) -> (x*3);

ANS: Implement secure


serialization by generating secure
object hash or using encryption.
Ensure that the class definition
used is the same as the class
definition used by Java runtime at
the time when the
object was serialized.
ANS: 10

ANS: 13579
ANS: 3.0

ANS:System.out.print(p1.relativize (p3));
System.out.print(p2.relativize (p3));

You might also like