1. 1)LEVELS find the unique character in this String
2. 2)proactive,achivements,Innovative ideas
3. 4)Have ever created used defined annothations
4. 5)A product value is changing every 15 mins a day .so 96 entries value a day .for n number of days
5. you need to give a Datastructure so that the UI people will render as it is
6. 6)Explain you project
Cognizant
1. we have XMl authors and Books.so i need a COllection that can we used so that if give bookid i have to get the authorname and viceversa
2. why we need to go to spring(LooseCoupling @ and Layer like controller,service,dao layer)
3. what is Lazy Loading
4. what is your project achitecture
5. how you consume REST Webservices write that Code
6. What are the Collections you are Using
INautuix
1. we have get the employeeName and managerName from employee table
2. select e.ename,mgr.ename from employee e,mgr where mgr.eid=e.eid
3. how can you sort the data using salary-Comparator
4. What are the Collections you are Using
L&T
1. HashCode Equals Contra
2. why we need hasing
3. write a program that to store 1-m in Hibernate
Bally
1. How will configure to connect to 2 Databases in Hibernate
2. how you will map UI one field to has-a class property in struts 2
3. what is OGNL ?how to retrive the session object to UI
4. diffrent scopes of JSP?
5. Joins in ORacle employee(id ,name)3 EmployeeDetails(id ,Location)4 ,if not there you need to show the value as NA instead of null
6. who can you constomize serilization?(using transient,Externalization)
7. what are other maker interface you Know(clonable)
8. why Clonnable ?what do you achieve form Clonnable
9. what is diffrence between Runnable and Callable
10. Employee(id,age,name)-i want to unique and sorting order
11. (we need to override equals() and hascode() and i have to use set -hashset/treeSet/linked hashset,and if you want to sort based on some descending order using comparator-)
12. can we sort the object in descending order in comparable -compareTO()?
13. 3 LT and 5 Lt tin is there .we should not use another tin .who can you achieve 4 lt with minimal number of iteration?
14. How will you consume rest web services
15. can we access the non synchronized method when we apply class level Lock
16. Concurrency Package
17. How can you access dependent object in Hibernate
18. what is Criteria and Projections
Written Test
1. convert Binary To decimal
2. convert Decimal to Binary
3. password validation
4. -length should be 8-15 characters
5. -at least one Uppercase Letter
6. –at least one Lowercase Letter
7. -at least one Number
8. -should have at least 1 special character
9. how to define user defined exception
==========================================
EMC
------
1)traverse the singlelinkedlist reverse
2)what is the output of the following
class A
{
public Integer add(Integer a,Integer b)
{
return a+b;
}
public Double add(Double a,Double b)
{
return a+b;
}
public static void main(String args[])
{
A a=new B();
a.printResult();//B will be excuted
}
public void printResult()
{
System.out.println("Welcome class A");
}
}
class B Extend A
{
public void printResult()
{
System.out.println("Welcome class B");
}
}
3)solve consumer and producer problem
4)There in method f() which return either 0 or 1.probabilityof getting 0/1 is same (50%
each).write a psudeo code to get 0 with 75% and 1 with 25% using same method f()
5)Say that a "clump" in an a series of 2 or more adjecent elements of the same
return the number of clumpsin the given array
{1,2,2,3,4,4} //2
{1,1,2,1,1,1} //2
{1,1,1,1,1,1} //1
write your own immutable class
1,2,5,8 ship at at time 2 members can travel,all the people has to cross the river
return time also should calculate total 15 mins should take
Class Test
{
public static void main(String args{})
{
String a="Hello";
String b="world";
System.out.println(a+b);//what is the output here
swap(a,b);
System.out.println(a+b);//what is the output here
}
public void (String a,string b)
{
String temp=a;
a=b;
b=temp;
}
}
OpenText
--------
1)How to avoid SQl Injection ,means in 1 SQL command we will give another SQL command which
always will return true
Select * from emp where eid=(select eid from emp where eid=1)
2)what will happen when there in interBean depedency
wheather the object is created or not or else any Exception will raise
3)what is static variable
4)Diffrence between SAX and DOM Parser
5)if you compile code in Java1.7 and execute in the java1.8 will it excute ? yes
if youcompile the code in Java1.8 and excute in the java1.7 ? will Excute ? no the what is
theException it will through
6)what is intern()?
7)who do you override a protected method?
written text
---------------
1)Find a word in the string which a character has before and after the vowel
2)find the 2 nd highest value in an array int array={7,3,8,9,16,14} --14
//bubble sort 2 nd iteration we will get the 2 nd highest in before last value
3)1st non repetative character in the string int s="india" //n
4)swap the 2 variables without 3 rd varaible int a=10;b=6; //a=a+b;a=a-b;b=a-b;
5)print the pairs whose sum is 15 in array ? int array[]={-5,-4,20,10,5,6,2,8} //(-5,20)
(10,5)
====================================================================
sum of digits of a number
sort map by value
perfect number or not
bubble sort,quick sort ,insertion sort
check given number binary/amstrong
common elements between 2 arrays
reverse string using recuression
2 strings are anagrams or not
create deadlock between threads
find the factors of the number from 1 to 100
find 2 nd largestet element in array
print numbers without using loops
find missing number in an array
find duplicate number in an array
find factorial of a large number
print duplicates from a string //sandeep print ee
remove duplicates from string in java
given number is even or odd
count the number of vowels in the string
print floyds triangle in java
binary search of a number
===========================
what is the diffrence between exception and Error
what is super class of all the exceptions
why we have compile time and run time exception ? we can have all @ runtime right ?
if you got a ArrayIndexOutOfBoundsException other that catching that exception how can you resolve it
what are the Rules of OVerriding
=======================================================================================================
if you have super and sub classes and m1 method you have ovverided in sub class. tell me the output
Class Super
{
public void m1(){//super m1()}
public void m2(){//super m2()}
public static void m3(){//super static m3()}
}
class sub extends Super
{
public void m1(){//sub m1() override}
public static void m3(){//sub method hidding}
public void m4(){//sub m4()}
}
Super s=new Sub();
s.m1()
s.m2()
s.m3()
s.m4()
=============================================================
String s="30 20 10 5 50 60" output is 5 10 20 30 50 60 ? how can you acheive it?
i want the only duplicate elements in list?
i want the only duplicate elements in 2 list?
How to remove duplicate elements in list?
how to find the missing element in a sorted array from 1 to 1000 in best way
how can you sort employee object based on age and salary and empid
employee class has a address property and in address class we have city property .i need to sort based on city how can we do it
what is serilization what is the use of it .if sub class is serilizable then parent class is also serilizable ?
what is the diffrence between serilization and externalization
if you don't want to seralize a variable who can you do it //before that property transient key word we have to use
have wrote any customized exception in spring
if string password="ABC";string password="XYZ" ; how many objects are created as you told string is immutable?
what is the diffrence between string buffer and string builder
what are collections classes and interfaces
(List,set,queque)
(ArrayList,LinkedList,vector,stack,hashset,LinkedHashset,Treeset)
map-HashMap,HashTable,LinkedHashMap,weekHashMap,TreeMap,identityHashMap
do you know any classes in concurrency package( use in multithreaded contexts: ConcurrentHashMap, ConcurrentSkipListMap, ConcurrentSkipListSet, CopyOnWriteArrayList, and CopyOnWriteArraySet. )
what is lifecycle of servlet,JSP
what is servlet config and servletContext
what are implicit objects of JSP(request,respose,application,session,out,config,page,exception,pageContext)
in how many ways we can able create the object?
what is diffrence between filter and listener?
what are diffrence scopes in JSP?
how can you handle a exception in jsp?
what is diffrence between jsp:include and jsp directive include
Session Tracking Techniques?in jsp
what is pageContext?
Have you ever created custum tags in jsp
what is the diffrernce between iterartor and listiterator and enumerations ?
if you iterating a list in for loop mean while another thread removing a value or adding a value what will happen //ConcurrentModificationException who can you avoid it
what is the internal implementation of hashmap
what is the internal implementation of concurrent hashmap
what is deadlock how can you avoid it
what is producer and consumer problem how can we achieve it
what is AOP,crosscutting concerns, joinpoint,pointcut,advice,target
what is ORM, what is diffrence between
Diffrence between load and get in hibernate
what is diffrence properties in configuration file
how can you connect to 2 DB in hibernate
======================================================
1)Courrent hashmap internal funtionallity
2)coding best practices
3)Tell the daily routine activities
4)rules of overriding
5)what is the equals and hashcode
.-what is syncronization
-what is serlization
-what is diffrence between serilization and externalization
-best way to create threads
-diffrence between runnable and callable
-what is the Thread pool
-what is diffrence between web server and application server
-how to remove duplicates from the list without using hashset
6)diffrence between comparable and comaprator
7)diffrence between string,stingbuffer,string builder
8)spring life cycle
9)how can you intergate spring and hibernate
10)design pattrens
11)diffrence between union and unionAll
12)what is diffrence between sub query and Corelated Query
13)what is index,clusterded index,b-tree
14)n th highest salary
15)diffrence between procedure and funtion in oracle
16)Triggers and cursors
17)what is AOP
18)best way to handle exception in MVC
19)diffrence between listner and filter
=============
20)Hibernate
1-m,m-1,m-m
what is diffrence b/w
load and get
21)i want the names of coloumn ending with kumar in hibernate
22)differnce between update and merge
24)diffrence between persist and save
25)diffrence between save and saveORUpdate
26) what is n+1 problem
27)what is the disadvantage of hibernate
28) how can you connect 2 databases
29)what is cascade,inverse
30)do you know profilers in java
how to remove duplicates from the list without using hashset
====================
@Transcation
@configuratioin-configure java beans
index
==========================================
2)coding best practices
3)Tell the daily routine activities
4)rules of overriding
5)what is the equals and hashcode
.-what is syncronization
-what is serlization
-what is diffrence between serilization and externalization
-best way to create threads
-diffrence between runnable and callable
-what is the Thread pool
-what is diffrence between web server and application server
-how to remove duplicates from the list without using hashset
6)diffrence between comparable and comaprator
7)diffrence between string,stingbuffer,string builder
8)spring life cycle
9)how can you intergate spring and hibernate
10)design pattrens
11)diffrence between union and unionAll
12)what is diffrence between sub query and Corelated Query
13)what is index,clusterded index,b-tree
14)n th highest salary
15)diffrence between procedure and funtion in oracle
16)Triggers and cursors
17)what is AOP
18)best way to handle exception in MVC
19)diffrence between listner and filter
=============
20)Hibernate
1-m,m-1,m-m
what is diffrence b/w
load and get
21)i want the names of coloumn ending with kumar in hibernate
22)differnce between update and merge
24)diffrence between persist and save
25)diffrence between save and saveORUpdate
26) what is n+1 problem
27)what is the disadvantage of hibernate
28) how can you connect 2 databases
29)what is cascade,inverse
30)do you know profilers in java
how to remove duplicates from the list without using hashset
====================
@Transcation
@configuratioin-configure java beans
index
============================
idx_sal-defaultly in asceding order
(ddresspart,data part)
select sal from emp where sal<7000;
performance is increased
-don't select data from index -it's not valid
after view is created we can get the index
-index is a 2 dimensional object just like a table.index maintaining coloumn data in ascedning order and addressport
addresspart=RowID-physical address of each record.based on this address only the record is fetching from the table .
Index=RowID(FileNO/TableNo,DataBaseNumber/rercordNumber)
simpleIndex eg:index on sal
--create Index idx_sal on EMp(sal)
compositeIndex
--create index idx_mfg_empId on prod_dtls(mfg,empid)
UniqueIndex
--create unique index idx_mobile on Cust_dtls(mobile);
reverse Index-serach data frequestly looking for highest value
--create index idx_sales_amt on sales(sales_amt) reverse
FuntionBased Index
if you used any funtion in the index
--create index idx_sal_1 on
Emp(sal,(0.10*sal),Initcap(ename));
bitMapIndex-like gender,employee active
--create bitmap index idx_gender
on customer(gender)
all index are search based on Btree index
-On every primary key Oracle maintains index internally
select constraint_name from user_constraints
where table_name='CUST_ACT_DTLS';
desc user_indexes;//to see all the indexes
To see the existing index on the CUST_ACT_DTLS
--select inde_name from user_indexes
where table_name='CUST-ACT_DTLS'
--idexes are develped on Binary tree or balanced tree
--select index_name from user_indexes
where table_name='EMP'
--drop index idx_comm;
==============================
pseudo coloums
Table level -RoWnUM,roWid,
rowNum -internally maintance serial numers for the records in the table
To get TOp n number of Rows form the table
=,>=,> not work <,<= will work
range of records can be taken[7-8] important for ETL developers by using set operators
-------------------------------------
select empno,ename,sal from emp where riwnum<9
minus
select empno,ename,sal,from emp where rownum<5
==========================================
EMC
------
1)traverse the singlelinkedlist reverse
2)what is the output of the following
class A
{
public Integer add(Integer a,Integer b)
{
return a+b;
}
public Double add(Double a,Double b)
{
return a+b;
}
public static void main(String args[])
{
A a=new B();
a.printResult();//B will be excuted
}
public void printResult()
{
System.out.println("Welcome class A");
}
}
class B Extend A
{
public void printResult()
{
System.out.println("Welcome class B");
}
}
3)solve consumer and producer problem
4)There in method f() which return either 0 or 1.probabilityof getting 0/1 is same (50%
each).write a psudeo code to get 0 with 75% and 1 with 25% using same method f()
5)Say that a "clump" in an a series of 2 or more adjecent elements of the same
return the number of clumpsin the given array
{1,2,2,3,4,4} //2
{1,1,2,1,1,1} //2
{1,1,1,1,1,1} //1
write your own immutable class
1,2,5,8 ship at at time 2 members can travel,all the people has to cross the river
return time also should calculate total 15 mins should take
Class Test
{
public static void main(String args{})
{
String a="Hello";
String b="world";
System.out.println(a+b);//what is the output here
swap(a,b);
System.out.println(a+b);//what is the output here
}
public void (String a,string b)
{
String temp=a;
a=b;
b=temp;
}
}
OpenText
--------
1)How to avoid SQl Injection ,means in 1 SQL command we will give another SQL command which
always will return true
Select * from emp where eid=(select eid from emp where eid=1)
2)what will happen when there in interBean depedency
wheather the object is created or not or else any Exception will raise
3)what is static variable
4)Diffrence between SAX and DOM Parser
5)if you compile code in Java1.7 and execute in the java1.8 will it excute ? yes
if youcompile the code in Java1.8 and excute in the java1.7 ? will Excute ? no the what is
theException it will through
6)what is intern()?
7)who do you override a protected method?
written text
---------------
1)Find a word in the string which a character has before and after the vowel
2)find the 2 nd highest value in an array int array={7,3,8,9,16,14} --14
//bubble sort 2 nd iteration we will get the 2 nd highest in before last value
3)1st non repetative character in the string int s="india" //n
4)swap the 2 variables without 3 rd varaible int a=10;b=6; //a=a+b;a=a-b;b=a-b;
5)print the pairs whose sum is 15 in array ? int array[]={-5,-4,20,10,5,6,2,8} //(-5,20)
(10,5)
====================================================================
sum of digits of a number
sort map by value
perfect number or not
bubble sort,quick sort ,insertion sort
check given number binary/amstrong
common elements between 2 arrays
reverse string using recuression
2 strings are anagrams or not
create deadlock between threads
find the factors of the number from 1 to 100
find 2 nd largestet element in array
print numbers without using loops
find missing number in an array
find duplicate number in an array
find factorial of a large number
print duplicates from a string //sandeep print ee
remove duplicates from string in java
given number is even or odd
count the number of vowels in the string
print floyds triangle in java
binary search of a number
===========================
what is the diffrence between exception and Error
what is super class of all the exceptions
why we have compile time and run time exception ? we can have all @ runtime right ?
if you got a ArrayIndexOutOfBoundsException other that catching that exception how can you resolve it
what are the Rules of OVerriding
=======================================================================================================
if you have super and sub classes and m1 method you have ovverided in sub class. tell me the output
Class Super
{
public void m1(){//super m1()}
public void m2(){//super m2()}
public static void m3(){//super static m3()}
}
class sub extends Super
{
public void m1(){//sub m1() override}
public static void m3(){//sub method hidding}
public void m4(){//sub m4()}
}
Super s=new Sub();
s.m1()
s.m2()
s.m3()
s.m4()
=============================================================
String s="30 20 10 5 50 60" output is 5 10 20 30 50 60 ? how can you acheive it?
i want the only duplicate elements in list?
i want the only duplicate elements in 2 list?
How to remove duplicate elements in list?
how to find the missing element in a sorted array from 1 to 1000 in best way
how can you sort employee object based on age and salary and empid
employee class has a address property and in address class we have city property .i need to sort based on city how can we do it
what is serilization what is the use of it .if sub class is serilizable then parent class is also serilizable ?
what is the diffrence between serilization and externalization
if you don't want to seralize a variable who can you do it //before that property transient key word we have to use
have wrote any customized exception in spring
if string password="ABC";string password="XYZ" ; how many objects are created as you told string is immutable?
what is the diffrence between string buffer and string builder
what are collections classes and interfaces
(List,set,queque)
(ArrayList,LinkedList,vector,stack,hashset,LinkedHashset,Treeset)
map-HashMap,HashTable,LinkedHashMap,weekHashMap,TreeMap,identityHashMap
do you know any classes in concurrency package( use in multithreaded contexts: ConcurrentHashMap, ConcurrentSkipListMap, ConcurrentSkipListSet, CopyOnWriteArrayList, and CopyOnWriteArraySet. )
what is lifecycle of servlet,JSP
what is servlet config and servletContext
what are implicit objects of JSP(request,respose,application,session,out,config,page,exception,pageContext)
in how many ways we can able create the object?
what is diffrence between filter and listener?
what are diffrence scopes in JSP?
how can you handle a exception in jsp?
what is diffrence between jsp:include and jsp directive include
Session Tracking Techniques?in jsp
what is pageContext?
Have you ever created custum tags in jsp
what is the diffrernce between iterartor and listiterator and enumerations ?
if you iterating a list in for loop mean while another thread removing a value or adding a value what will happen //ConcurrentModificationException who can you avoid it
what is the internal implementation of hashmap
what is the internal implementation of concurrent hashmap
what is deadlock how can you avoid it
what is producer and consumer problem how can we achieve it
what is AOP,crosscutting concerns, joinpoint,pointcut,advice,target
what is ORM, what is diffrence between
Diffrence between load and get in hibernate
what is diffrence properties in configuration file
how can you connect to 2 DB in hibernate
======================================================
1)Courrent hashmap internal funtionallity
2)coding best practices
3)Tell the daily routine activities
4)rules of overriding
5)what is the equals and hashcode
.-what is syncronization
-what is serlization
-what is diffrence between serilization and externalization
-best way to create threads
-diffrence between runnable and callable
-what is the Thread pool
-what is diffrence between web server and application server
-how to remove duplicates from the list without using hashset
6)diffrence between comparable and comaprator
7)diffrence between string,stingbuffer,string builder
8)spring life cycle
9)how can you intergate spring and hibernate
10)design pattrens
11)diffrence between union and unionAll
12)what is diffrence between sub query and Corelated Query
13)what is index,clusterded index,b-tree
14)n th highest salary
15)diffrence between procedure and funtion in oracle
16)Triggers and cursors
17)what is AOP
18)best way to handle exception in MVC
19)diffrence between listner and filter
=============
20)Hibernate
1-m,m-1,m-m
what is diffrence b/w
load and get
21)i want the names of coloumn ending with kumar in hibernate
22)differnce between update and merge
24)diffrence between persist and save
25)diffrence between save and saveORUpdate
26) what is n+1 problem
27)what is the disadvantage of hibernate
28) how can you connect 2 databases
29)what is cascade,inverse
30)do you know profilers in java
how to remove duplicates from the list without using hashset
====================
@Transcation
@configuratioin-configure java beans
index
==========================================
Which value will be if return a value after finally Block?
class ExceptionRetrunExample {
public static void main(String[] args) {
System.out.println(getValue());
}
public static int getValue() {
try {
// int x = 1 / 0;
// return 1;
} catch (ArithmeticException ae) {
return 2;
} catch (Exception e) {
return 3;
} finally {
// return 4;
}
return 5;
}
}
Output : 5
Example on Method Overriding and Method Hiding
class Super {
public void m1() {
System.out.println("1super m1()");
}
public void m2() {
System.out.println("2super m1()");
}
public static void m3() {
System.out.println("3Super static m3()");
}
}
class Sub extends Super {
public void m1() { //comment this Method when you executing 2 Scenario1
System.out.println("4sub m1() override");
}
public static void m3() {
System.out.println("5sub method hidding");
}
public void m4() {
System.out.println("6sub m4()}");
}
public static void main(String[] args) {
//1 Scerio
Super s=new Sub();
s.m1();
s.m2();
s.m3();
// s.m4();//The method m4() is undefined for the type Super
//2 Scenario
/*Sub s1=new Sub();
s1.m1();*/
}
}
Scenario1 :output
4sub m1() override
2super m1()
3Super static m3()
========================================================================
1)Courrent hashmap internal funtionallity
Scenario2 :output when you comment m1 method in the Sub class
1super m1()
Java 8 Features
- Lambda expression − Adds functional processing capability to Java.
- Method references − Referencing functions by their names instead of invoking them directly. Using functions as parameter.
- Default method − Interface to have default method implementation.
- New tools − New compiler tools and utilities are added like ‘jdeps’ to figure out dependencies.
- Stream API − New stream API to facilitate pipeline processing.
- Date Time API − Improved date time API.
- Optional − Emphasis on best practices to handle null values properly.
- Nashorn, JavaScript Engine − A Java-based engine to execute JavaScript code.
Lambda expression
Syntax
The basic syntax of a lambda is either
(parameters) -> expression
or
(parameters) -> { statements; }
Example
1. (int x, int y) -> x + y // takes two integers and returns their sum
2. (x, y) -> x - y // takes two numbers and returns their difference
3. () -> 42 // takes no values and returns 42
4. (String s) -> System.out.println(s) // takes a string, prints its value to the console, and returns nothing
5. x -> 2 * x // takes a number and returns the result of doubling it
6. c -> { int s = c.size(); c.clear(); return s; } // takes a collection, clears it, and returns its previous size
operation
|
interface used
|
λ signature
|
return type
|
return value
|
sample lazy/intermediate operations
| ||||
filter
|
T ➞ boolean
|
Stream<T>
|
stream containing input elements that satisfy the Predicate
| |
map
|
T ➞ R
|
Stream<R>
|
stream of values, the result of applying the Function to each input element
| |
sorted
|
(T, T) ➞ int
|
Stream<T>
|
stream containing the input elements, sorted by the Comparator
| |
limit, skip
|
Stream<T>
|
stream including only (resp. skipping) first n input elements
| ||
sample eager/terminal operations
| ||||
reduce
|
(T, T) ➞ T
|
Optional<T>
|
result of reduction of input elements (if any) using supplied BinaryOperator
| |
findFirst
|
T ➞ boolean
|
Optional<T>
|
first input element satisfying Predicate (if any)
| |
forEach
|
T ➞ void
|
void
|
void, but applies the method of supplied Consumer to every input element
|
Lambda expressions can be used only in the following four contexts.
- Assignment Context
- Method Invocation Context
- Return Context
- Cast ContextThere are six types of method reference.
- TypeName::staticMethod - reference to a static method of a class, an interface, or an enum
- objectRef::instanceMethod - reference to an instance method
- ClassName::instanceMethod - reference to an instance method from a class
- TypeName.super::instanceMethod - reference to an instance method from the supertype of an object
- ClassName::new - reference to the constructor of a class
- ArrayTypeName::new - reference to the constructor of the specified array typehttp://www.java2s.com/Tutorials/Java/Java_Lambda/0130__Java_Static_Method_Reference.htmStream Exampleimport java.util.Arrays;import java.util.IntSummaryStatistics;import java.util.List;import java.util.stream.Collectors;public class Java8Streams{public static void main(String args[]) {// Count the empty stringsList<String> strList = Arrays.asList("rajesh", "", "avinash", "", "dinesh", "jakeer");long count = strList.stream().filter(x -> x.isEmpty()).count();System.out.printf("List %s has %d empty strings %n", strList, count);// Count String with length more than 3long num = strList.stream().filter(x -> x.length()> 3).count();System.out.printf("List %s has %d strings of length more than 3 %n", strList, num);// Count number of String which startswith "a"count = strList.stream().filter(x -> x.startsWith("a")).count();System.out.printf("List %s has %d strings which startsWith 'a' %n", strList, count);// Remove all empty Strings from ListList<String> filtered = strList.stream().filter(x -> !x.isEmpty()).collect(Collectors.toList());System.out.printf("Original List : %s, List without Empty Strings : %s %n", strList, filtered);// Create a List with String more than 2 charactersfiltered = strList.stream().filter(x -> x.length()> 2).collect(Collectors.toList());System.out.printf("Original List : %s, filtered list : %s %n", strList, filtered);// Convert String to Uppercase and join them using comaList<String> G7 = Arrays.asList("USA", "Japan", "France", "Germany", "Italy", "U.K.","Canada");String G7Countries = G7.stream().map(x -> x.toUpperCase()).collect(Collectors.joining(", "));System.out.println(G7Countries);// Create List of square of all distinct numbersList<Integer> numbers = Arrays.asList(9, 10, 3, 4, 7, 3, 4);List<Integer> distinct = numbers.stream().map( i -> i*i).distinct().collect(Collectors.toList());System.out.printf("Original List : %s, Square Without duplicates : %s %n", numbers, distinct);//Get count, min, max, sum, and average for numbersList<Integer> primes = Arrays.asList(2, 3, 5, 7, 11, 13, 17, 19, 23, 29);IntSummaryStatistics stats = primes.stream().mapToInt((x) -> x).summaryStatistics();System.out.println("Highest prime number in List : " + stats.getMax());System.out.println("Lowest prime number in List : " + stats.getMin());System.out.println("Sum of all prime numbers : " + stats.getSum());System.out.println("Average of all prime numbers : " + stats.getAverage());}}What is Prototype in JavaScriptEvery JavaScript object has an internal property called [[Prototype]]. If you look up a property via obj.propName or obj['propName'] and the object does not have such a property - which can be checked via obj.hasOwnProperty('propName') - the runtime looks up the property in the object referenced by [[Prototype]] instead. If the prototype-object also doesn't have such a property, its prototype is checked in turn, thus walking the original object's prototype-chain until a match is found or its end is reached.Some JavaScript implementations allow direct access to the [[Prototype]] property, eg via a non-standard property named __proto__. In general, it's only possible to set an object's prototype during object creation: If you create a new object via new Func(), the object's [[Prototype]] property will be set to the object referenced by Func.prototype.This allows to simulate classes in JavaScript, although JavaScript's inheritance system is - as we have seen - prototypical, and not class-based:Just think of constructor functions as classes and the properties of the prototype (ie of the object referenced by the constructor function's prototype property) as shared members, ie members which are the same for each instance. In class-based systems, methods are implemented the same way for each instance, so methods are normally added to the prototype, whereas an object's fields are instance-specific and therefore added to the object itself during construction.Ref : http://stackoverflow.com/questions/572897/how-does-javascript-prototype-work
No comments:
Post a Comment