Can you declare a class as ‘private’?
No, if we declare a class as private, then it is not available to java compiler and hence a compile time error occurs. But, inner class can be declared as private.
What are static methods?
Static methods are methods which do not act upon the instance variables of a class. Static methods are declared as ‘static’.
Reason: JVM executes the static methods and then only it creates the objects.
What are static blocks?
A static block is a block of statements declared as ‘static’,some thing like this:
JVM executes a static block on a highest priority basis. This means JVM first goes to static block even before it looks for the main() method in the program.
public static void main(string args)
Output: static block
Is it possible to compile and run a java program without writing main() method?
Yes, it is possible by using a static block in the java program.
We know that the class code along with method code is stored in “method area” of the JVM. When an object is created, the memory is allocated on ‘heap‘. After creation of an object, JVM produces a unique identifier number for the object from the memory address of the object. This reference number is called hashcode number.
To know the hashcode number of an object, we can use hashcode() method of object class as shown here..
Employee el=new Employee();
The Java Heap Space is the memory “container” of you runtime Java program which provides to your Java program the proper memory spaces it needs (Java Heap, Native Heap) and managed by the JVM itself.
Your Java program life cycle typically looks like this:
– Java program coding (via Eclipse IDE etc.) e.g. HelloWorld.java
– Java program compilation (Java compiler or third party build tools such as Apache Ant, Apache Maven..) e.g. HelloWord.class
– Java program start-up and runtime execution e.g. via your HelloWorld.main() method
The Java Heap space is mainly applicable and important for the third step: runtime execution. For the HotSpot VM, the Java Heap Space is split in 3 silos:
– Java Heap for short & long lived objects (YoungGen & OldGen spaces)
– PermGen space
– Native Heap
Now let’s dissect your HelloWorld.class program so you can better understand.
– At start-up, your JVM will load and cache some of your static program and JDK libraries to the Native Heap, including native libraries, Mapped Files such as your program Jar file(s), Threads such as the main start-up Thread of your program etc.
– Your JVM will then store the “static” data of your HelloWorld.class Java program to the PermGen space (Class metadata, descriptors..)
– Once your program is started, the JVM will then manage and dynamically allocate the memory of your Java program to the Java Heap (YoungGen & OldGen). This is why it is so important that you understand how much memory your Java program needs to you can properly fine-tuned the capacity of your Java Heap controlled via –Xms & -Xmx JVM parameters. Profiling, Heap Dump analysis allow you to determine your Java program memory footprint
– Finally, the JVM has to also dynamically release the memory from the Java Heap Space that your program no longer need; this is called the garbage collection process. This process can be easily monitored via the JVM verbose GC or a monitoring tool of your choice such as JConsole
Most of the java beginners donno what is JVM and how the architecture of it will be i.e., JVM Inside..Lets explore what it is..
What is JVM??
In simple words,
- Java Virtual Machine is not a real hardware machine but a software layer which resembles an hardware platform.
- JVM converts java byte code into machine language and executes it
- The byte code can be executed on any platform where jvm exists.
JVM Inside(JVM Architecture)
1. Class loader sub system: JVM’s class loader sub system performs 3 tasks
a. It loads .class file into memory.
b. It verifies byte code instructions.
c. It allots memory required for the program.
2. Run time data area: This is the memory resource used by JVM and it is divided into 5 parts
a. Method area: Method area stores class code and method code.
b. Heap: Objects are created on heap.
c. Java stacks: Java stacks are the places where the Java methods are executed. A Java stack contains frames. On each frame, a separate method is executed.
d. Program counter registers: The program counter registers store memory address of the instruction to be executed by the micro processor.
e. Native method stacks: The native method stacks are places where native methods (for example, C language programs) are executed. Native method is a function, which is written in another language other than Java.
3. Native method interface: Native method interface is a program that connects native methods libraries (C header files) with JVM for executing native methods.
4. Native method library: holds the native libraries information.
5. Execution engine: Execution engine contains interpreter and JIT compiler, which covert byte code into machine code. JVM uses optimization technique to decide which part to be interpreted and which part to be used with JIT compiler. The HotSpot represent the block of code executed by JIT compiler.
I hope you are well aware of 2 step verification for your accounts..if not?? pls clickhere to know what it is..
Today we will see what is google authenticator and how to use it..
What is exactly this google authenticator??
Google Authenticator implements TOTP security tokens from RFC6238 in mobile apps made by Google, sometimes branded “two-step authentication”. The Authenticator provides a six digit one-time password users must provide in addition to their username and password to log into Google services. With two-step authentication enabled, you’ll be prompted to enter a six-digit number after you provide your username and password. Unlike a PIN number for an ATM, this six-digit number changes with every login.
How to use this??
Doing the two-step
1. Make sure two-step authentication is enabled for your Google account
Before you start using the app, make sure that two-step authentication is enabled and configured for your account.
2. Install the app
Download and install the app on your Android device
3. Connect Google Authenticator to your Google Account
Just goto your newly installed google authenticator app. Now goto options->set up account.
Now you can see two different procedures..
1. Manually add an account
2. Available google accounts
Just check your gmail account in available google accounts. click on your account..this will show a pop up screen like beginning setup..Then you will be alerted with account already enrolled. Now click on scan barcode.
Note: Make sure you have barcode scanner app in your mobile.
Now just open your browser in desktop and login to your account..it will show a barcode in your desktop browser..with your mobile barcode scanner..just scan that barcode..thats it.your job is done..your account is highly secured with google authenticator 😀
Folks, Two-factor authentication is one of the best things you can do to make sure your accounts don’t get hacked.
What is Two Step Authentication??
Passwords, unfortunately, aren’t as secure as they used to be, and if someone gets your password, they can access your account without any fuss. Even having a strong password doesn’t completely protect you. Two-factor authentication solves this problem.
Here’s a list of all the popular services that offer it, and where you should go to turn it on right now.
- Google/Gmail: Google’s two-factor authentication sends you a 6-digit code via text message when you attempt to log in from a new machine, though it also works with the Google Authenticator app for Android, iOS, and BlackBerry. You can save each machine for 30 days. You can enable it here, or check out Google’s documentation for more info.
- Apple: Apple’s two-factor authentication sends you a 4-digit code via text message or Find My iPhone notifications when you attempt to log in from a new machine. You canenable it here, or check out Apple’s documentation for more info.P
- Facebook: Facebook’s two-factor authentication, called “Login Approvals,” sends you a 6-digit code via text message when you attempt to log in from a new machine. It also works with apps like Google Authenticator for Android, iOS, and BlackBerry, as well as the “Code Generator” feature of the Facebook app. You can also authorize a new machine from Facebook.com on a saved machine if you don’t have your phone handy. You can enable it here, or check out Facebook’s blog for more info.
- Twitter: Twitter’s two-factor authentication sends you a 6-digit code via text message when you attempt to log in from a new machine. You can enable it here, or check outTwitter’s blog for more info.P
- Dropbox: Dropbox’s two-factor authentication sends you a 6-digit code via text message when you attempt to log in from a new machine, though it also works with Google Authenticator and a few other similar authentication apps. You can enable it here, or check out Dropbox’s documentation for more info. And if you want another layer of extra security, you can encrypt the contents of your Dropbox with TrueCrypt.
- Microsoft Accounts: Microsoft’s two-factor authentication sends you a 7-digit code via text message or email when you attempt to log in from a new machine, though it also works with a number of authenticator apps. You can enable it here, or check out Microsoft’s documentation for more info.P
- Yahoo! Mail: Yahoo’s two-factor authentication sends you a 6-digit code via text message when you attempt to log in from a new machine. You can enable it here, or check out About.com’s article on the subject for more info.
- LinkedIn: LinkedIn’s two-factor authentication sends you a 6-digit code via text message when you attempt to log in from a new machine. You can enable it here, or check outLinkedIn’s blog for more info.
- WordPress: WordPress supports two-factor authentication via the Google Authenticatorapp for Android, iOS, and BlackBerry. You can enable it and read more about it here.
I hope few well known about pipe concept, the easiest way to transfer files in internet. Anyways iam sharing this post for people who are unaware of this 😉
If you want to send a doc/image/video etc from mobile(browser enabled) to desktop (or) browser enabled mobile to browser enabled mobile (or) desktop to desktop. Anything is mere like elementary act ;).
A website offers this functionality just like peer-to-peer connection(not theoritically :P). Just logon to Pipebytes and upload your file and copy the url or code and click send file. Now just share that code/url with your friend who need to paste that code in receive section and then hit pickup file. Thats it..now your coveted file will get download over your friend machine/mobile/anything.
Follow the screenshots for better understanding..
Fairly simple right?? 🙂