TERRA LOGIC COMPANY ( call based 2017 , 2018 batch )

******************************************
TERRA LOGIC COMPANY ( call based 2017 , 2018 batch )
***************************************\
Candidates meeting the following criteria can apply:

drive date 20 -4-2018

Educational Qualification: BE/B.Tech/MCA/ME/M.Tech
Branch: Computer Science/ IT/ ECE
Year of pass: 2017 and 2018 only
Minimum percentage: 65%
Mandatory skills: Excellent programming skills in any one of the language (Networking, C/C++/Java/Python/Perl or any programming language)
Should have good communication skills in English
Passion to build career in programming and Software development
Job Details
Company Name: Terralogic Software Solutions Pvt Ltd
Work location: Bangalore

Address: 1st Main Rd, Koramangala Industrial Layout, Koramangala, Bengaluru, Karnataka 560034

LINK TO APPLY
********************************
http://my-jobhunter.com/bangalore/bangalore-new-links/
*********************************

***********************************************************************

1. Apti+Coding(basics)
2. Self Introduction(In front of CEO)
3. Technical(Basics of C & java)
4. Two HR rounds

***************************************************
Time and Distance
Time and Work
Compound Interest
Partnership
Problems on Ages
Clock

********************************************
A can do a work in 15 days and B in 20 days. If they work on it together for 4 days, then the fraction of the work that is left is :

A.
1
4
B.
1
10
C.
7
15
D.
2.
A can lay railway track between two given stations in 16 days and B can do the same job in 12 days. With help of C, they did the job in 4 days only. Then, C alone can do the job in:

A.
9 1 days
5
B.
9 2 days
5
C.
9 3 days
5
D. 10
3.
A, B and C can do a piece of work in 20, 30 and 60 days respectively. In how many days can A do the work if he is assisted by B and C on every third day?

A. 12 days
B. 15 days
C. 16 days
D. 18 days
4.
A is thrice as good as workman as B and therefore is able to finish a job in 60 days less than B. Working together, they can do it in:

A. 20 days
B.
22 1 days
2
C. 25 days
D. 30 days
5.
A alone can do a piece of work in 6 days and B alone in 8 days. A and B undertook to do it for Rs. 3200. With the help of C, they completed the work in 3 days. How much is to be paid to C?

A. Rs. 375
B. Rs. 400
C. Rs. 600
D. Rs. 800
11.
A can finish a work in 18 days and B can do the same work in 15 days. B worked for 10 days and left the job. In how many days, A alone can finish the remaining work?

A. 5
B.
5 1
2
C. 6
D. 8
View Answer Discuss in Forum Workspace Report
12.
4 men and 6 women can complete a work in 8 days, while 3 men and 7 women can complete it in 10 days. In how many days will 10 women complete it?

A. 35
B. 40
C. 45
D. 50
View Answer Discuss in Forum Workspace Report
13.
A and B can together finish a work 30 days. They worked together for 20 days and then B left. After another 20 days, A finished the remaining work. In how many days A alone can finish the work?

A. 40
B. 50
C. 54
D. 60
View Answer Discuss in Forum Workspace Report
14.
P can complete a work in 12 days working 8 hours a day. Q can complete the same work in 8 days working 10 hours a day. If both P and Q work together, working 8 hours a day, in how many days can they complete the work?

A.
5 5
11
B.
5 6
11
C.
6 5
11
D.
6 6
11
**************************************************************************************************

1. Aptitude-(60 questions -60 minutes) linux, c, general aptitude questions. I didnt attend linux questions. c and aptitude questions were easy to get qualified for next round.
2. Coding Round – answer any 3 from 5 questions.Just write code in a paper (c/c++/java/perl/php)
3. Technical Interview – (Face to face interview) self introduction, project related questions, simple programs, basic cs questions

Variable Number of Arguments – Find Output of Program
Variable Number of Arguments – Find Output of Program
Variable Number of Arguments – Point Out Errors
Variable Number of Arguments – True / False Questions
Variable Number of Arguments – Yes / No Questions
1.
What will be the output of the program?
#include
#include
void fun(char *msg, …);

int main()
{
fun(“IndiaBIX”, 1, 4, 7, 11, 0);
return 0;
}
void fun(char *msg, …)
{
va_list ptr;
int num;
va_start(ptr, msg);
num = va_arg(ptr, int);
num = va_arg(ptr, int);
printf(“%d”, num);
}
A. IndiaBIX 1 7 11 0
B. 1
C. 4
D. 7
View Answer Discuss in Forum C Compiler Report
2.
What will be the output of the program?
#include
#include
void fun1(char, int, int *, float *, char *);
void fun2(char ch, …);
void (*p1)(char, int, int *, float *, char *);
void (*p2)(char ch, …);

int main()
{
char ch=’A’; int i=10;
float f=3.14; char *p=”Hello”;
p1=fun1;
p2=fun2;
(*p1)(ch, i, &i, &f, p);
(*p2)(ch, i, &i, &f, p);
return 0;
}
void fun1(char ch, int i, int *pi, float *pf, char *p)
{
printf(“%c %d %d %f %s \n”, ch, i, *pi, *pf, p);
}
void fun2(char ch, …)
{
int i, *pi; float *pf; char *p;
va_list list;
printf(“%c “, ch);
va_start(list, ch);
i = va_arg(list, int);
printf(“%d “, i);

pi = va_arg(list, int*);
printf(“%d “, *pi);
pf = va_arg(list, float*);
printf(“%f “, *pf);
p = va_arg(list, char *);
printf(“%s”, p);
}
A. A 10 3.14
A 10 3.14
B. A 10 10 3.140000 Hello
A 10 10 3.140000 Hello
C. A 10 Hello
A 10 Hello
D. Error
View Answer Discuss in Forum C Compiler Report
3.
What will be the output of the program?
#include
#include
void dumplist(int, …);

int main()
{
dumplist(2, 4, 8);
dumplist(3, 6, 9, 7);
return 0;
}
void dumplist(int n, …)
{
va_list p; int i;
va_start(p, n);

while(n–>0)
{
i = va_arg(p, int);
printf(“%d”, i);
}
va_end(p);
printf(“\n”);
}
A. 2 4
3 6
B. 2 4 8
3, 6, 9, 7
C. 4 8
6 9 7
D. 1 1 1
1 1 1 1
View Answer Discuss in Forum C Compiler Report
4.
What will be the output of the program?
#include
#include
void display(int num, …);

int main()
{
display(4, ‘A’, ‘B’, ‘C’, ‘D’);
return 0;
}
void display(int num, …)
{
char c, c1; int j;
va_list ptr, ptr1;
va_start(ptr, num);
va_start(ptr1, num);
for(j=1; j<=num; j++) { c = va_arg(ptr, int); printf("%c", c); c1 = va_arg(ptr1, int); printf("%d\n", c1); } } A. A, A B, B C, C D, D B. A, a B, b C, c D, d C. A, 65 B, 66 C, 67 D, 68 D. A, 0 B, 0 C, 0 C, 0 View Answer Discuss in Forum C Compiler Report 5. What will be the output of the program? #include
#include
void fun1(int num, …);
void fun2(int num, …);

int main()
{
fun1(1, “Apple”, “Boys”, “Cats”, “Dogs”);
fun2(2, 12, 13, 14);
return 0;
}
void fun1(int num, …)
{
char *str;
va_list ptr;
va_start(ptr, num);
str = va_arg(ptr, char *);
printf(“%s “, str);
}
void fun2(int num, …)
{
va_list ptr;
va_start(ptr, num);
num = va_arg(ptr, int);
printf(“%d”, num);
}
A. Dogs 12
B. Cats 14
C. Boys 13
D. Apple 12

LINUX QUESTION
*******************************************
https://www.indiabix.com/computer-science/linux/

*******************************************

What command is used to count the total number of lines, words, and characters contained in a file?
A. countw
B. wcount
C. wc
D. count p
E. None of the above
2.
What command is used to remove files?
A. dm
B. rm
C. delete
D. erase
E. None of the above

3.
What command is used to remove the directory?
A. rdir
B. remove
C. rd
D. rmdir
E. None of the above
View Answer Discuss in Forum Workspace Report
4.
What command is used with vi editor to delete a single character?
A. x
B. y
C. a
D. z
E. None of the above
View Answer Discuss in Forum Workspace Report
5.
What hardware architectures are not supported by Red Hat?
A. SPARC
B. IBM-compatible
C. Alpha
D. Macintosh
E. None of the above

***********************************************************************************

*******************************************************************************************
SECOND
coding round:
******************************************************************************************
1. Quick sort(Compulsory)
2. find second largest element of an array without sorting
3. check weather even or odd without using division and modulus operator
4. count number of occurance of each character in a string.
5. find power of a number.
**********************************************************************************
2ND ROUND

Coding Round – answer any 3 from 5 questions.Just write code in a paper (c/c++/java/perl/php)

*************************************************************************
INTERVIEW
****************************************************************
3. Technical Interview – (Face to face interview) self introduction, project related questions, simple programs, basic cs questions

C Program to Multiply two Floating Point Numbers
C Program to Find ASCII Value of a Character
C Program to Compute Quotient and Remainder
C Program to Find the Size of int, float, double and char
C Program to Demonstrate the Working of Keyword long
C Program to Swap Two Numbers
C Program to Check Whether a Number is Even or Odd
C Program to Check Whether a Character is Vowel or Consonant
C Program to Find the Largest Number Among Three Numbers
C program to Find all Roots of a Quadratic equation
C Program to Check Leap Year
C Program to Check Whether a Number is Positive or Negative
C Program to Check Whether a Character is an Alphabet or not
C Program to Calculate the Sum of Natural Numbers
C Program to Find Factorial of a Number
C Program to Generate Multiplication Table
C Program to Display Fibonacci Sequence
C Program to Find GCD of two Numbers
C Program to Find LCM of two Numbers
C Program to Display Characters from A to Z Using Loop
C Program to Count Number of Digits in an Integer
C Program to Reverse a Number

***********************************************************************************************************

1. Quick sort(Compulsory)
2. find second largest element of an array without sorting
3. check weather even or odd without using division and modulus operator
4. count number of occurance of each character in a string.
5. find power of a number.

Bubble sort without using third variable

quick sort
some integers have to stored using command line argument and find the index value of one them

sum of prime numbers(like that)

remove the vowels from a string

interview1: print triangle

interview: string reverse without string length function

1. Which two method you need to implement for key Object in HashMap ?
In order to use any object as Key in HashMap, it must implements equals and hashcode method in Java. Read How HashMap works in Java for detailed explanation on how equals and hashcode method is used to put and get object from HashMap.

2. What is immutable object? Can you write immutable object?Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.

3. What is the difference between creating String as new() and literal?
When we create string with new() Operator, it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in PermGen area of heap.

String s = new String(“Test”);

does not put the object in String pool , we need to call String.intern() method which is used to put them into String pool explicitly. its only when you create String object as String literal e.g. String s = “Test” Java automatically put that into String pool.

4. What is difference between StringBuffer and StringBuilder in Java ?

Classic Java questions which some people thing tricky and some consider very easy. StringBuilder in Java is introduced in Java 5 and only difference between both of them is that Stringbuffer methods are synchronized while StringBuilder is non synchronized. See StringBuilder vs StringBuffer for more differences.

5. Write code to find the First non repeated character in the String ?
Another good Java interview question, This question is mainly asked by Amazon and equivalent companies. See first non repeated character in the string : Amazon interview question

6. What is the difference between ArrayList and Vector ?
This question is mostly used as a start up question in Technical interviews on the topic of Collection framework . Answer is explained in detail here Difference between ArrayList and Vector .

7. How do you handle error condition while writing stored procedure or accessing stored procedure from java?
This is one of the tough Java interview question and its open for all, my friend didn’t know the answer so he didn’t mind telling me. my take is that stored procedure should return error code if some operation fails but if stored procedure itself fail than catching SQLException is only choice.

8. What is difference between Executor.submit() and Executer.execute() method ?
There is a difference when looking at exception handling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you don’t have provided one explicitly, the default one will just print the stack trace to System.err). If you submitted the task with submit any thrown exception, checked exception or not, is then part of the task’s return status. For a task that was submitted with submit and that terminates with an exception, the Future.get will re-throw this exception, wrapped in an ExecutionException.

9. What is the difference between factory and abstract factory pattern?
Abstract Factory provides one more level of abstraction. Consider different factories each extended from an Abstract Factory and responsible for creation of different hierarchies of objects based on the type of factory. E.g. AbstractFactory extended by AutomobileFactory, UserFactory, RoleFactory etc. Each individual factory would be responsible for creation of objects in that genre.
You can also refer What is Factory method design pattern in Java to know more details.

10. What is Singleton? is it better to make whole method synchronized or only critical section synchronized ?
Singleton in Java is a class with just one instance in whole Java application, for example java.lang.Runtime is a Singleton class. Creating Singleton was tricky prior Java 4 but once Java 5 introduced Enum its very easy. see my article How to create thread-safe Singleton in Java for more details on writing Singleton using enum and double checked locking which is purpose of this Java interview question.

11. Can you write critical section code for singleton?
This core Java question is followup of previous question and expecting candidate to write Java singleton using double checked locking. Remember to use volatile variable to make Singleton thread-safe.

12. Can you write code for iterating over hashmap in Java 4 and Java 5 ?
Tricky one but he managed to write using while and for loop.

13. When do you override hashcode and equals() ?
Whenever necessary especially if you want to do equality check or want to use your object as key in HashMap.

14. What will be the problem if you don’t override hashcode() method ?
You will not be able to recover your object from hash Map if that is used as key in HashMap.
See here How HashMap works in Java for detailed explanation.

15. Is it better to synchronize critical section of getInstance() method or whole getInstance() method ?
Answer is critical section because if we lock whole method than every time some one call this method will have to wait even though we are not creating any object)

16. What is the difference when String is gets created using literal or new() operator ?
When we create string with new() its created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.

17. Does not overriding hashcode() method has any performance implication ?
This is a good question and open to all , as per my knowledge a poor hashcode function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.

18. What’s wrong using HashMap in multithreaded environment? When get() method go to infinite loop ?
Another good question. His answer was during concurrent access and re-sizing.

19. What do you understand by thread-safety ? Why is it required ? And finally, how to achieve thread-safety in Java Applications ?

Java Memory Model defines the legal interaction of threads with the memory in a real computer system. In a way, it describes what behaviors are legal in multi-threaded code. It determines when a Thread can reliably see writes to variables made by other threads. It defines semantics for volatile, final & synchronized, that makes guarantee of visibility of memory operations across the Threads.

Let’s first discuss about Memory Barrier which are the base for our further discussions. There are two type of memory barrier instructions in JMM – read barriers and write barrier.

A read barrier invalidates the local memory (cache, registers, etc) and then reads the contents from the main memory, so that changes made by other threads becomes visible to the current Thread.
A write barrier flushes out the contents of the processor’s local memory to the main memory, so that changes made by the current Thread becomes visible to the other threads.
JMM semantics for synchronized
When a thread acquires monitor of an object, by entering into a synchronized block of code, it performs a read barrier (invalidates the local memory and reads from the heap instead). Similarly exiting from a synchronized block as part of releasing the associated monitor, it performs a write barrier (flushes changes to the main memory)
Thus modifications to a shared state using synchronized block by one Thread, is guaranteed to be visible to subsequent synchronized reads by other threads. This guarantee is provided by JMM in presence of synchronized code block.

JMM semantics for Volatile fields
Read & write to volatile variables have same memory semantics as that of acquiring and releasing a monitor using synchronized code block. So the visibility of volatile field is guaranteed by the JMM. Moreover afterwards Java 1.5, volatile reads and writes are not reorderable with any other memory operations (volatile and non-volatile both). Thus when Thread A writes to a volatile variable V, and afterwards Thread B reads from variable V, any variable values that were visible to A at the time V was written are guaranteed now to be visible to B.

Let’s try to understand the same using the following code

Data data = null;
volatile boolean flag = false;

Thread A
————-
data = new Data();
flag = true; <-- writing to volatile will flush data as well as flag to main memory Thread B ------------- if(flag==true){ <-- as="" barrier="" data.="" flag="" font="" for="" from="" perform="" read="" reading="" volatile="" well="" will="">
use data;