TutorMe homepage
Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Krutarth N.
Development Engineer in Oracle
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

How to use static in java? what is the output of following program? class A { static int i; static { System.out.println(1); i = 100; } } public class StaticInitializationBlock { static { System.out.println(2); } public static void main(String[] args) { System.out.println(3); System.out.println(A.i); } }

Krutarth N.
Answer:

Firstly before calling main the static block in class StaticInitializationBlock will execute and 2 will be printed. Then 3 will be printed by simple output command in the main function. Later the 'i' variable of class A will be called and its value will be printed. But its value is initialized in static block so it will execute first by first printing 1 and then printing the value of i i.e 100. Output: 2 3 1 100

Trigonometry
TutorMe
Question:

How to solve questions in Trogonometry?

Krutarth N.
Answer:

Main problem in solving questions in trigonometry is visualization by different angles. It comes through practice when you can see multiple angles,sides and ratios and comapre them to find the required sides or ratios. Trigonometry concepts are vastly used in the field of finding the depth of ocean , height of buildings,etc

C++ Programming
TutorMe
Question:

What are pointers in C++? Most of the students gets difficulty in Pointers.

Krutarth N.
Answer:

Pointers are nothing but special variable which stores the address of the the normal variable in C and C++ programming. You can access the value of the pointers by the unary operator *. For example: // C program to demonstrate use of * for pointers in C #include <stdio.h> int main() { // A normal integer variable int Var = 10; // A pointer variable that holds address of var. int *ptr = &Var; // This line prints value at address stored in ptr. //Value stored is value of variable "var" printf("Value of Var = %d\n", *ptr); // The output of this line may be different in different runs even on same machine. printf("Address of Var = %p\n", ptr); // We can also use ptr as lvalue (Left hand side of assignment) *ptr = 20; // Value at address is now 20 // This prints 20 printf("After doing *ptr = 20, *ptr is %d\n", *ptr); return 0; } Output : Value of Var = 10 Address of Var = 0x7fffa057dd4 After doing *ptr = 20, *ptr is 20

Send a message explaining your
needs and Krutarth will reply soon.
Contact Krutarth
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.